Ejemplo n.º 1
0
    function sendInvoiceEmail($row_booking_id)
    {
        $db = new Application_Model_DbTable_DbGlobal();
        $row_booking = $db->getBookingById($row_booking_id, 1);
        $row_booking_detail = $db->getBookingById($row_booking_id, 2);
        $pickup_date = date_create($row_booking["pickup_date"]);
        $return_date = date_create($row_booking["return_date"]);
        $diff = date_diff($pickup_date, $return_date);
        $total_day = $diff->format("%a%") + 1;
        if ($row_booking["rental_type"] == 1) {
            $duration = " Day(s)";
            $total_duration = $total_day;
        } elseif ($row_booking["rental_type"] == 2) {
            $duration = " Monthly";
            $total_duration = $row_booking["total_duration"];
        }
        $htmlContent = '<div style="font-family:Arial;font-size:10px">
	<table align="center" style="width:100%" border="0" cellspacing="0" cellpadding="0">
		<tbody>
			<tr>
				<td>
					<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0" style="width:100% !important;font-family:Arial;font-size:12px">
						<tbody>
							<tr>
								<td>
									<table width="100%" align="left" border="0" cellspacing="0" cellpadding="0" style="font-family:Arial;font-size:12px">
										<tbody>
											<tr>
												<td>
													<table width="100%" align="center" style="background:#FBFF00">
														<tr align="center" style="height:12px;font-size: 30px;">
															<td><span style="color:red;font-family:"Kh Kangrey">លីណា-ជួលរថយន្តទេសចរណ៍</span></td>
														</tr>
														<tr align="center" style="height: 12px;font-size: 30px;">
															<td><span style="color:red; font-family:"Bocci Regular ttnorm">Lyna-CarRental.Com</span></td>
														</tr>
														<tr align="center" style="height: 12px;font-size: 30px;background:#0C109E;border-top:2px solid #ffffff;">
															<td><span style="color:red;"></span></td>
														</tr>
													</table>
												</td>
											</tr>
											<tr style="height:30px"><td><hr /></td></tr>
											<tr bgcolor="#ffffff">
												<td>
													<table width="100%" align="left" border="0" cellspacing="0" cellpadding="0" style="font-family:Arial;font-size:12px">
														<tbody>';
        if ($row_booking["item_type"] == 1) {
            $htmlContent .= '<tr border="1">
																<td width="25%" align="left">Bill For : </td>
																<td width="25%"align="left">' . $row_booking["customer_name"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right"></td>
																<td width="30%" align="right"></td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">Phone No. : </td>
																<td width="25%"align="left">' . $row_booking["customer_phone"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right"></td>
																<td width="30%" align="right"></td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">E-mail Address : </td>
																<td width="25%"align="left">' . $row_booking["customer_email"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Flight No.:</td>
																<td width="30%" align="right">' . $row_booking["fly_no"] . '</td>
															</tr>';
            $htmlContent .= '<tr>
																<td width="25%" align="left">Pickup Date and Time:</td>
																<td width="25%" align="left">' . $row_booking["pickup_date"] . " " . $row_booking["pickup_time"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Flight Date:</td>
																<td width="30%" align="right">' . $row_booking["fly_date"] . '</td>
															</tr>
															<tr>
																<td width="25%" align="left">Pickup Location:</td>
																<td width="25%" align="left">' . $row_booking["pickup_location"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right"> Time of Arrival:</td>
																<td width="30%" align="right">' . $row_booking["fly_time_of_arrival"] . '</td>
															</tr>
															<tr>
																<td width="25%" align="left">Return Date and Time:</td>
																<td width="25%" align="left">' . $row_booking["return_date"] . " " . $row_booking["return_time"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Destination:</td>
																<td>' . $row_booking["fly_destination"] . '</td>
															</tr>
															 <tr>
																<td width="25%" align="left">Return Location:</td>
																<td width="25%" align="left">' . $row_booking["return_location"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Booking No.: </td>
																<td width="30%" align="right" style="color:red;"><b style="color:red">' . $row_booking["booking_no"] . '</b></span></td>
															</tr>
															<tr>
																<td align="left">Duration :</td>
																<td align="left">' . $total_day . $duration . '</td>
																<td></td>
																<td width="15%" align="right">Booking Date: </td>
																<td width="30%" align="right">' . $row_booking["date_book"] . '</td>
															</tr>';
        } elseif ($row_booking["item_type"] == 2) {
            $htmlContent .= '<tr border="1">
																<td width="25%" align="left">Bill For : </td>
																<td width="25%"align="left">' . $row_booking["customer_name"] . '</td>
																<td width="15%" align="right"></td>
																<td width="30%" align="right"></td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">Phone No. : </td>
																<td width="25%"align="left">' . $row_booking["customer_phone"] . '</td>
																<td width="15%" align="right">Flight No.:</td>
																<td width="30%" align="right">' . $row_booking["fly_no"] . '</td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">E-mail Address : </td>
																<td width="25%"align="left">' . $row_booking["customer_email"] . '</td>
																<td width="15%" align="right">Flight Date:</td>
																<td width="30%" align="right">' . $row_booking["fly_no"] . '</td>
															</tr>';
            $htmlContent .= '<tr>
																<td width="25%" align="left">Pickup Date and Time:</td>
																<td width="30%" align="left">' . $row_booking["pickup_date"] . " " . $row_booking["pickup_time"] . '</td>
																<td width="15%" align="right">Distination:</td>
																<td width="30%" align="right">' . $row_booking["fly_no"] . '</td>
															</tr>
															<tr>
																<td width="25%" align="left">Pickup Location:</td>
																<td width="30%" align="left">' . $row_booking["pickup_location"] . '</td>
																<td width="15%" align="right"> Time of Arrival:</td>
																<td width="30%" align="right">' . $row_booking["fly_time_of_arrival"] . '</td>
															</tr>
															 <tr>
																<td width="25%" align="left">Return Location:</td>
																<td width="30%" align="left">' . $row_booking["return_location"] . '</td>
																<td width="15%" align="right">Books No: </td>
																<td width="30%" align="right"><b style="color:red">' . $row_booking["booking_no"] . '</b></td>
															</tr>
															<tr>
																<td align="left">Trip Way :</td>
																<td align="left">' . $row_booking["date_book"] . '</td>
																<td width="15%" align="right">Books Date: </td>
																<td width="30%" align="right">' . $row_booking["date_book"] . '</td>
															</tr>';
        } elseif ($row_booking["item_type"] == 3) {
            $htmlContent .= '<tr border="1">
																<td width="25%" align="left">Bill For : </td>
																<td width="25%"align="left">' . $row_booking["customer_name"] . '</td>
																<td width="15%" align="right"></td>
																<td width="30%" align="right"></td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">Phone No. : </td>
																<td width="25%"align="left">' . $row_booking["customer_phone"] . '</td>
																<td width="15%" align="right">Flight No.:</td>
																<td width="30%" align="right">' . $row_booking["fly_no"] . '</td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">E-mail Address : </td>
																<td width="25%"align="left">' . $row_booking["customer_email"] . '</td>
																<td width="15%" align="right">Flight Date:</td>
																<td width="30%" align="right">' . $row_booking["fly_date"] . '</td>
															</tr>';
            $htmlContent .= '<tr>
																<td width="25%" align="left">Package Name :</td>
																<td width="30%" align="left">' . $row_booking["package_location"] . '</td>
																<td width="15%" align="right">Distination:</td>
																<td width="30%" align="right">' . $row_booking["fly_destination"] . '</td>
															</tr>
															<tr>
																<td width="25%" align="left">Pickup Date and Time:</td>
																<td width="30%" align="left">' . $row_booking["pickup_date"] . " " . $row_booking["pickup_time"] . '</td>
																<td width="15%" align="right"> Time of Arrival:</td>
																<td width="30%" align="right">' . $row_booking["fly_time_of_arrival"] . '</td>
															</tr>
															<tr>
																<td width="25%" align="left">Pickup Location:</td>
																<td width="30%" align="left">' . $row_booking["pickup_location"] . '</td>
																<td width="15%" align="right">Booking No: </td>
																<td width="30%" align="right"><b style="color:red">' . $row_booking["booking_no"] . '</b></td>
															</tr>
															 <tr style="border-bottom:1px solid #000000;">
																<td width="25%" align="left">Return Location:</td>
																<td width="30%" align="left">' . $row_booking["return_location"] . '</td>
																<td width="15%" align="right">Booking Date: </td>
																<td width="30%" align="right">' . $row_booking["date_book"] . '</td>
															</tr>';
        } elseif ($row_booking["item_type"] == 4) {
            $htmlContent .= '<tr border="1">
																<td width="25%" align="left">Bill For : </td>
																<td width="25%"align="left">' . $row_booking["customer_name"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Flight No.:</td>
																<td width="30%" align="right">' . $row_booking["fly_no"] . '</td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">Phone No. : </td>
																<td width="25%"align="left">' . $row_booking["customer_phone"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Flight Date:</td>
																<td width="30%" align="right">' . $row_booking["fly_date"] . '</td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">E-mail Address : </td>
																<td width="25%"align="left">' . $row_booking["customer_email"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Distination:</td>
																<td width="30%" align="right">' . $row_booking["fly_destination"] . '</td>
															</tr>';
            $htmlContent .= '<tr>
																<td width="25%" align="left">Pickup Date and Time:</td>
																<td width="25%" align="left">' . $row_booking["pickup_date"] . " " . $row_booking["pickup_time"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right"> Time of Arrival:</td>
																<td width="30%" align="right">' . $row_booking["fly_time_of_arrival"] . '</td>
															</tr>
															
															<tr>
																<td width="25%" align="left">Return Date and Time:</td>
																<td width="25%" align="left">' . $row_booking["return_date"] . " " . $row_booking["return_time"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Books No: </td>
																<td width="30%" align="right" style="color:red;"><b style="color:red">' . $row_booking["booking_no"] . '</b></span></td>
															</tr>
															<tr>
																<td align="left">Duration :</td>
																<td align="left">' . $total_day . '</td>
																<td></td>
																<td width="15%" align="right">Books Date: </td>
																<td width="30%" align="right">' . $row_booking["date_book"] . '</td>
															</tr>';
        } elseif ($row_booking["item_type"] == 5) {
            $htmlContent .= '<tr border="1">
																<td width="25%" align="left">Bill For : </td>
																<td width="25%"align="left">' . $row_booking["customer_name"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Flight No.:</td>
																<td width="30%" align="right">' . $row_booking["fly_no"] . '</td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">Phone No. : </td>
																<td width="25%"align="left">' . $row_booking["customer_phone"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Flight Date:</td>
																<td width="30%" align="right">' . $row_booking["fly_date"] . '</td>
															</tr>
															<tr border="1">
																<td width="25%" align="left">E-mail Address : </td>
																<td width="25%"align="left">' . $row_booking["customer_email"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Distination:</td>
																<td width="30%" align="right">' . $row_booking["fly_destination"] . '</td>
															</tr>';
            $htmlContent .= '<tr>
																<td width="25%" align="left">Pickup Date and Time:</td>
																<td width="25%" align="left">' . $row_booking["pickup_date"] . " " . $row_booking["pickup_time"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right"> Time of Arrival:</td>
																<td width="30%" align="right">' . $row_booking["fly_time_of_arrival"] . '</td>
															</tr>
															
															<tr>
																<td width="25%" align="left">Return Date and Time:</td>
																<td width="25%" align="left">' . $row_booking["return_date"] . " " . $row_booking["return_time"] . '</td>
																<td width="5%"></td>
																<td width="15%" align="right">Books No: </td>
																<td width="30%" align="right" style="color:red;"><b style="color:red">' . $row_booking["booking_no"] . '</b></span></td>
															</tr>
															<tr>
																<td align="left">Duration :</td>
																<td align="left">' . $row_booking["total_duration"] . $duration . '</td>
																<td></td>
																<td width="15%" align="right">Books Date: </td>
																<td width="30%" align="right">' . $row_booking["date_book"] . '</td>
															</tr>';
        }
        $htmlContent .= '<tr height="30px" bgcolor="#ffffff" style="border-bottom:1px solid #000000;"><td colspan="5"><hr /></td> </tr>';
        $htmlContent .= '</tbody>
													</table>
												</td>
											</tr>
											<tr bgcolor="#ffffff">
												<td>
													<table style="width:100%; border-collapse: collapse;font-family:Arial;font-size:12px" border="0" align="center" cellspacing="0" cellpadding="0">
														<tbody>
															<tr style="background:rgb(82, 132, 253);    height: 40px; border: 1px solid #000000; color:#ffffff">
																<td align="center" style="border: 1px solid #000000;">No. </td>
																<td align="center" style="border: 1px solid #000000;">Items Description</td>
																<td align="center" style="border: 1px solid #000000;">QTY</td>
																<td align="center" style="border: 1px solid #000000;">Price</td>
																<td align="center" style="border: 1px solid #000000;">VAT</td>
																<td align="center" style="border: 1px solid #000000;">Amount</td>
															</tr>';
        $refun_de = 0;
        foreach ($row_booking_detail as $key => $rs) {
            $i = $key + 1;
            if ($row_booking["item_type"] == 1 or $row_booking["item_type"] == 4) {
                $amount = ($rs["price"] * $rs["rent_num"] + $rs["price"] * $rs["rent_num"] * $rs["VAT"]) * $total_day;
            } elseif ($row_booking["item_type"] == 2 or $row_booking["item_type"] == 3) {
                $amount = $rs["price"] * $rs["rent_num"] + $rs["price"] * $rs["rent_num"] * $rs["VAT"];
            } elseif ($row_booking["item_type"] == 5) {
                $amount = ($rs["price"] * $rs["rent_num"] + $rs["price"] * $rs["rent_num"] * $rs["VAT"]) * $row_booking["total_duration"];
            }
            $refun_de += $rs["refund_deposit"];
            $htmlContent .= '<tr style="height: 30px;border: 1px solid #000000;">';
            $htmlContent .= '<td align="center" style="padding-left:8px;width:5%; border: 1px solid #000000;">' . $i . '</td>';
            $htmlContent .= '<td align="left" style="padding-left:8px;width:52%;border: 1px solid #000000;">' . $rs["item_name"] . '</td>';
            $htmlContent .= '<td align="center" style="border: 1px solid #000000;width:8%">' . $rs["rent_num"] . '</td>';
            $htmlContent .= '<td align="right" style="border: 1px solid #000000; width:10%; padding-right:5px;" nowrap="nowrap">$' . number_format($rs["price"], 2) . '</td>';
            $htmlContent .= '<td align="right" style="border: 1px solid #000000; width:10%; padding-right:5px;" nowrap="nowrap">%' . number_format($rs["VAT"], 2) . '</td>';
            $htmlContent .= '<td align="right" style="border: 1px solid #000000; width:15%; padding-right:5px;" nowrap="nowrap">$' . number_format($amount, 2) . '</td>';
            $htmlContent .= '</tr>';
        }
        $net_total = $row_booking["total_fee"] + $refun_de;
        $due_total = $net_total - $row_booking["deposite_fee"];
        $htmlContent .= '<tr style="height: 25px;border:0px !important;">';
        $htmlContent .= '<td align="center" style="padding-left:0px;" colspan="3"></td>';
        $htmlContent .= '<td align="right" colspan="2" style="border: 1px solid #000000; padding-right:5px;" nowrap="nowrap">Rental Fee:</td>';
        $htmlContent .= '<td align="right" style="border: 1px solid #000000;padding-right:5px;" nowrap="nowrap">US$' . number_format($row_booking["total_fee"], 2) . '</td>';
        $htmlContent .= '</tr>';
        if ($row_booking["item_type"] == 1) {
            $htmlContent .= '<tr style="height: 25px;border:0px !important;">';
            $htmlContent .= '<td align="center" style="padding-left:8px;" colspan="3"></td>';
            $htmlContent .= '<td align="right" colspan="2" style="border: 1px solid #000000;padding-right:5px;" nowrap="nowrap">Refundable Deposit:</td>';
            $htmlContent .= '<td align="right" style="border: 1px solid #000000;padding-right:5px;" nowrap="nowrap">US$' . number_format($refun_de, 2) . '</td>';
            $htmlContent .= '</tr>';
            $htmlContent .= '<tr style="height: 25px;border:0px !important;">';
            $htmlContent .= '<td align="center" style="padding-left:8px;" colspan="3"></td>';
            $htmlContent .= '<td align="right" colspan="2" style="border: 1px solid #000000;padding-right:5px;" nowrap="nowrap">Amount Paid (<span style="font-size:10px;">50% + Bank Charge 3%</span>):</td>';
            $htmlContent .= '<td align="right" style="border: 1px solid #000000;padding-right:5px;" nowrap="nowrap">US$' . number_format($row_booking["deposite_fee"], 2) . '</td>';
            $htmlContent .= '</tr>';
        }
        $htmlContent .= '<tr style="height: 25px;border:0px !important;">';
        $htmlContent .= '<td align="left" style="padding-left:0px;" colspan="3" rowspan="2"><span style="font-size: 11px"><b style="color:red">ចំណាំ:</b> សូមបង្ហាញនូវសារអេឡិចត្រូនិច ឬ ក្រដាស់ដែលបានថតចម្លង ពីការកក់រថយន្តរបស់អ្នក នៅពេលការមកដល់របស់អ្នក។</span><br/>
																			<span style="font-size: 12px"><b style="color:red">Note:</b> Please present either an electronic or paper copy of your vehicle booking sheet upon your arrival.</span>
																			</td>';
        $htmlContent .= '<td align="right" colspan="2" style="border: 1px solid #000000; padding-right:5px;" nowrap="nowrap">Net Total:</td>';
        $htmlContent .= '<td align="right" style="border: 1px solid #000000; padding-right:5px;" nowrap="nowrap">US$' . number_format($net_total, 2) . '</td>';
        $htmlContent .= '</tr>';
        $htmlContent .= '<tr style="height: 25px;border:0px !important;">';
        //$htmlContent.='<td align="center" style="padding-left:0px;" border="0" colspan="3"><span style="font-size: 12px"><b style="color:red">Note:</b> Please present either an electronic or paper copy of your vehicle booking sheet upon your arrival.</span></td>';
        $htmlContent .= '<td align="right" colspan="2" style="border: 1px solid #000000; padding-right:5px;" nowrap="nowrap">Due Total:</td>';
        $htmlContent .= '<td align="right" style="border: 1px solid #000000; padding-right:5px;" nowrap="nowrap">US$' . number_format($due_total, 2) . '</td>';
        $htmlContent .= '</tr>';
        $htmlContent .= '</tbody>
													</table>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</tbody>
	</table>
</div>';
        //print_r($htmlContent);exit();
        if ($row_booking["payment_type"] == 1) {
            $payment_type = "VISA CARD";
        } elseif ($row_booking["payment_type"] == 2) {
            $payment_type = "WESTERN UNION";
        } else {
            $payment_type = "ACLEDA UNITY";
        }
        $user_info = '<div style="font-family:Arial;font-size:10px">
	<table align="left" width="50%" border="0" cellspacing="0" cellpadding="0" style="width:50% !important;font-family:Arial;font-size:10px;">
		<tr style="background: #4484F1;height: 30px" >
			<td colspan="2" style="padding-left: 10px;color: white;">
				Customer Payment Info
			</td>
		</tr>
		<tr style="height: 25px">
			<td>
				Payment Tye :
			</td>
			<td>
				' . $payment_type . '
			</td>
		</tr>';
        if ($row_booking["payment_type"] == 1) {
            $user_info .= '<tr style="height: 25px">
			<td>
				Card Name  :
			</td>
			<td>
				' . $row_booking["visa_name"] . '
			</td>
		</tr>
		<tr style="height: 25px">
			<td>
				Card Number  :
			</td>
			<td>
				' . $row_booking["card_id"] . '
			</td>
		</tr>
		<tr style="height: 25px">
			<td>
				CVV  :
			</td>
			<td>
				' . $row_booking["secu_code"] . '
			</td>
		</tr>
		<tr style="height: 25px">
			<td>
				Expiration Date  :
			</td>
			<td>
				' . $row_booking["card_exp_date"] . '
			</td>
		</tr>';
        } elseif ($row_booking["payment_type"] == 2) {
            $user_info .= '<tr style="height: 25px">
			<td>
				Code Number  :
			</td>
			<td>
				' . $row_booking["card_id"] . '
			</td>
		</tr>';
        }
        $user_info .= '</table>
</div>';
        print_r($htmlContent);
        exit;
        $to_Email_user = $row_booking["customer_email"];
        //Replace with recipient email address
        $to_Email_admin = "*****@*****.**";
        //Replace with recipient email address
        $subject = 'Lyna-Carrental.Com - Reservation Invoice';
        //Subject line for emails
        $headers = 'MIME-Version: 1.0' . "\r\n";
        //$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
        $headers .= 'From: ' . $to_Email_admin . "\r\n" . 'Reply-To: ' . $to_Email_user . "\r\n" . 'X-Mailer: PHP/' . phpversion();
        $sentMail = @mail($to_Email_admin, $subject, $htmlContent . '<br />' . $user_info, $headers);
        $sentMail = @mail($to_Email_user, $subject, $htmlContent, $headers);
        if (!$sentMail) {
            $return = "HTTP/1.1 500 Could not send mail! Sorry..";
        } else {
            $return = 'Hi ' . $row_booking["customer_name"] . ', Thank you for your Booking! ';
            $return .= 'Your email has been delivered.';
        }
        return $return;
    }
Ejemplo n.º 2
0
 function emailinvoiceAction()
 {
     $this->_helper->layout()->disableLayout();
     $id = $this->getRequest()->getParam("id");
     $db = new Application_Model_DbTable_DbGlobal();
     $row_booking = $db->getBookingById($id, 1);
     $row_booking_detail = $db->getBookingById($id, 2);
     $this->view->booking = $row_booking;
     $this->view->booking_detail = $row_booking_detail;
 }