<html xmlns="http://www.w3.org/1999/xhtml">

<head> </head>
<style>
table tr:first-child > td > center {
	/*background: #ff0000;*/
}

.bs-main{
display: inline-flex;
}
.lstyle{
list-style:none;
}

</style>

<body>
	<table style="background:#fff; border:#000000 1px solid;" width="622" cellspacing="0" cellpadding="0" border="0" align="center">
		<tbody>
			<tr class="first">
				<td>
					<center> <img width="500" height="100" src="<? if($this->layout_data['logo']['logo_image']){
                    echo get_image($this->layout_data['logo']['logo_image_path'],$this->layout_data['logo']['logo_image']);}
                    else{echo get_image($this->layout_data['logo'][0]['logo_image_path'], $this->layout_data['logo'][0]['logo_image']);}?>" style="padding: 15px;"> </center>
				</td>
			</tr>
			<tr>
				<td height="1"></td>
			</tr>
			<tr>
				<td style="font-family:Arial, Helvetica, sans-serif;" bgcolor="#f5f9f6">
					<table width="622" cellspacing="0" cellpadding="0" border="0" align="center">
						<tbody>
						    <tr>
						        <td align="right" style="padding-right: 19px;">
						            <a href="<?=base_url()?>invoices/<?=md5('Invoice-'.$order_detail['order_id'])?>.pdf" download>Download as PDF</a>
						        </td>
						    </tr>
							<tr>
								<td style="font-size:16px; padding:0px 15px; text-align:left">
									<p><strong>Dear <?=ucfirst($order_detail['order_firstname'])." ".ucfirst($order_detail['order_lastname'])?></strong></p>
								</td>
							</tr>
							<tr>
								<td style="font-size:15px; line-height:22px; padding:0 15px; margin-bottom:15px;"> This email is to let you know that we have received your order. Thank you for shopping with us. Below are your order details: </td>
							</tr>
							
							<tr>
							    <td style="font-size:16px; padding:0px 15px; text-align:left">
							       <div class= "bs-main" style="display:inline-flex;  width:100%">
                                    <div style="width:50%">
                                    <ul style="list-style:none;padding:0">
                                        <li><strong>Billing Details:</strong></li>
                                        <li><?=$order_detail['order_billing_firstname'].' '.$order_detail['order_billing_lastname']?></li>
                                        <li><?=$order_detail['order_billing_address']?></li>
                                        <li class="asd"><?= $order_detail['order_billing_city']; ?>, <?= $order_detail['order_billing_state']; ?>, <?= ($order_detail['order_billing_country']=='USA')?'United States':$order_detail['order_billing_country'] ?>, <?= $order_detail['order_billing_zip'];?></li>
                                        <!--<li>Myrtle Beach,South Carolina,United States,29588</li>-->
                                        <li>T: <?=$order_detail['order_billing_phone']?></li>
                                    </ul>
                                    </div>
                                    
                                    <div style="width:50%">
                                    
                                    <ul style="list-style:none;padding:0">
                                        <li><strong>Shipping Details:</strong></li>
                                        <li><?=$order_detail['order_shipping_firstname'].' '.$order_detail['order_shipping_lastname']?></li>
                                        <li><?=$order_detail['order_shipping_address1']?></li>
                                        <li class="asd2"><?= $order_detail['order_shipping_city']; ?>, <?= $order_detail['order_shipping_state']; ?>, <?= ($order_detail['order_shipping_country']=='USA')? 'United States':$order_detail['order_shipping_country']; ?>, <?= $order_detail['order_shipping_zip']; ?></li>
                                        <!--<li>Myrtle Beach,South Carolina,United States,29588</li>-->
                                        <li>T: <?=$order_detail['order_shipping_phone']?></li>
                                    </ul>
                                    </div>
                                    </div>
							    </td>
							</tr>
							
							<tr style="margin:20px 0; float:left;height:86px;" bgcolor="#006599">
								<td width="622">
									<table style="margin-top:20px;" width="580" cellspacing="0" cellpadding="0" border="0" align="center">
										<tbody style="font-size: 18px;">
											<tr style="color:#fff;  ">
												<td width="251" align="left ">Order number : <b><?=$order_detail['order_number'];?></b></td>
												<td width="50">&nbsp;</td>
												<?php

                                if (isset($this->percent_amount) && !empty($this->percent_amount)) {?>
													<td width="251" align="left ">You got <b><?=- $this->session->userdata('discount_amount')?></b> discount</td>
													<?

                                }

                                ?>
														<td width="50">&nbsp;</td>
														<td width="251" align="right">Order date :
															<?=date('d-M-Y', strtotime($order_detail['order_createdon']));?>
														</td>
											</tr>
											<tr style="color:#fff">
												<td width="251" align="left">Order status : <span style="font-size:18px;font-weight:bold">

                    <?php
            if($order_detail['order_payment_status'] == 1){ ?>
                <span class="label label-order-completed">Delivered</span>
    													<?php } elseif($order_detail['order_payment_status'] == 2){?> <span class="label label-order-pending">Order Placed</span>
    													<?php } elseif($order_detail['order_payment_status'] == 3){ ?> <span class="label label-order-processing">Processing</span>
    													<?php } elseif($order_detail['order_payment_status'] == 4){ ?> <span class="label label-order-dispatched">Dispatched</span>
    													<?php } elseif($order_detail['order_payment_status'] == 5){ ?> <span class="label label-order-hold">Hold</span>
    													<?php } elseif($order_detail['order_payment_status'] == 6){?> <span class="label label-order-cancelled">Cancelled</span>
    													<?php } elseif($order_detail['order_payment_status'] == 7){?> <span class="label label-order-declined">Card Declined</span>
    													<?php } elseif($order_detail['order_payment_status'] == 8){?> <span class="label label-order-refunded">Refunded</span>
    													<?}?>
													</span>
												</td>
												<td width="25">&nbsp;</td>
												<td width="25">&nbsp;</td>
												<?

                                $total = 0;

                                foreach($cart as $item): 

                                    $total = $total + ($item['qty']*$item['price']);

                                endforeach;

                                ?>
													<td style="font-size: 18px;padding: 5px 0px;" id="total_sum" width="251" align="right">Total Amount:
														<?=price($order_detail['order_amount'])?>
													</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
							    
							    <? $tracking_numbers = explode(',', $order_detail['order_tracking_number']);
							    foreach($tracking_numbers as $key=>$value):
							    if(trim($value) != ''):
							    ?>
								<tr>
									<td style="font-size:15px; line-height:22px; padding:0 15px; margin-bottom:15px;">
										<b>Tracking Number<?if(count($tracking_numbers)>1){echo ' '.($key+1);}?> : <?=$value?></b>
										<br>
									</td>
							    </tr>
							    <?endif;endforeach?>
							    
									<tr style="margin:0px 0; float:left; height:50px;" bgcolor="#f6f5f5">
										<td width="622">
											<table style="margin-top:15px;" width="580" cellspacing="0" cellpadding="0" border="0" align="center">
												<tbody>
													<tr style="color:#000;  ">
														<td style="font-size:28px;" width="251" align="left ">Payment details</td>
													</tr>
												</tbody>
											</table>
										</td>
									</tr>
									<tr style="float:left; padding:0 0 10px;border-bottom: 1px solid #cbcaca; margin-bottom:15px; " bgcolor="#f6f5f5">
										<td width="622">
											<table style="margin-top:20px;" width="580" cellspacing="0" cellpadding="0" border="0" align="center">
												<tbody>
													<?
                                foreach($cart as $item): ?>
														<?php
                                        $option = unserialize($item['order_item_option']);
                                        // debug($option,1);
                                    ?>
															<tr style="color:#000; height:30px;  ">
																<td colspan="3" width="251" align="left"> <b>Product Name :</b>
																	<?=$item['product_name']?>
																		<?php
                                            if (isset($option['product_color']) && !empty($option['product_color'])) {
                                        ?>
																			<p><b>Color: </b>
																				<?=$option['product_color']?>
																			</p>
																			<?php
                                            }
                                        ?> <b></b> </td>
															</tr>
															<tr style="color:#000; height:30px;  ">
																<td width="251" align="left "> <b>Sub total</b> (
																	<?= "Item : ".$item['order_item_qty']?> X
																		<?=price($item['order_item_price'])?>) </td>
																<td width="50">&nbsp;</td>
																<td width="251" align="right">
																	<?=price($item['order_item_qty']*$item['order_item_price'])?>
																</td>
															</tr>
															<?

                                endforeach;?>
																<tr>
																	<td colspan="3" style="color:#000;font-weight:bold">
																		<hr> </td>
																</tr>
																<tr style="color:#000;height:30px;">
																	<td width="251" align="left">Sub Total</td>
																	<td width="50">&nbsp;</td>
																	<td width="251" align="right">
																		<?=price($order_detail['order_total'])?>
																	</td>
																</tr>
																
																<tr style="color:#000;height:30px;">
																	<td width="251" align="left">Tax</td>
																	<td width="50">&nbsp;</td>
																	<td width="251" align="right">
																		<?=price($order_detail['order_tax'])?>
																	</td>
																</tr>
																
																<tr style="color:#000;height:30px;">
																	<td width="251" align="left">Shipping</td>
																	<td width="50">&nbsp;</td>
																	<td width="251" align="right">
																		<?=price($order_detail['order_shipment_price'])?>
																	</td>
																</tr>
																
																<tr style="color:#000;height:30px;">
																	<td width="251" align="left">Merchant Fee</td>
																	<td width="50">&nbsp;</td>
																	<td width="251" align="right">
																		<?=price(($order_detail['order_total']*$order_detail['order_merchantfee'])/100)?>
																	</td>
																</tr>
																
																<?php if (!empty($order_detail['order_custom_field'])): 
																    $fields = explode(',', $order_detail['order_custom_field']);
																    foreach ($fields as $key=>$field):
                                                    			    $field_name = explode(':', $field)[0];
                                                    			    $field_val = explode(':', $field)[1];
																?>
																	<tr style="color:#000;height:30px;">
																		<td width="251" align="left"><?=$field_name?></td>
																		<td width="50">&nbsp;</td>
																		<td width="251" align="right">
																			<?=price($field_val)?>
																		</td>
																	</tr>
																<?php endforeach;
																endif;
																
																if (!empty($order_detail['order_coupon_discount'])): ?>
																	<tr style="color:#000;height:30px;">
																		<td width="251" align="left">Discount</td>
																		<td width="50">&nbsp;</td>
																		<td width="251" align="right">
																			<?=price($order_detail['order_coupon_discount'])?>
																		</td>
																	</tr>
																	<?php endif ?>
																		<tr style="color:#000;height:30px;">
																			<td width="251" align="left">Total</td>
																			<td width="50">&nbsp;</td>
																			<td width="251" align="right">
																				<?=price($order_detail['order_amount'])?>
																			</td>
																		</tr>
												</tbody>
											</table>
										</td>
									</tr>
									<tr>
									    <tr>
    										<td style="font-size:13px; line-height:22px; padding:0 15px; margin-bottom:15px; padding-bottom:10px; text-align:center; font-weight:800;">NOTE: Please note the charge will appear on your Credit/Debit Card Bank Statement under the Name of: "CrispTech LLC"</td>
    									</tr>
    
    									<tr>
    									    <td style="font-size:13px; line-height:22px; padding:0 15px; margin-bottom:15px; padding-bottom:10px; text-align:center; font-weight:800;"></td>
    									</tr>
									    <!--<td style="font-size:10px; line-height:22px; padding:0 15px; margin-bottom:15px; padding-bottom:10px;text-align:center;">Refurbished items might have minor scratches or slightly wear and tear</td>-->

										<td style="font-size:10px; line-height:22px; padding:0 15px; margin-bottom:15px; padding-bottom:10px;text-align:center;">Refurbished items might have minor scratches or slightly wear and tear. <a href="<?=base_url()?>policies">Click here to view our polices</a><br/>To make sure our emails reach your inbox, please add
											<a href="mailto:<?=g('db.admin.email')?>">
												<?=g('db.admin.email')?>
											</a> to your safe list or address book.
											<br>
											
											<!-- Please note that there will be a delivery charge for re-sending returned items if an incorrect address has been provided. <br /> -->
										</td>
									</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</tbody>
	</table>
</body>

</html>