<?php
session_start();

require_once "../config.php";

require_once "../ajax/send_email.php";
$databaseFile = '../../uploads/geolite/ip.mmdb';
require_once "../../translation.php";
require_once "../../translation_ee.php";
require_once "../../translation_lt.php";

require_once "../../translation_en.php";
require_once "../../translation_fi.php";



require_once '../database1.php';
require_once "../check_admin.php";

class edit_orders extends database
{
    public function index($data,$dataItem,$id)
    {
		$where['cl_id']= $id;
        $this->dbh = $this->connectPDO1();
        $this->dbh->beginTransaction();
        try
        {

		  $res = $this->update1('tb_checkout',$data, $where);
          if(!$res)
          {
           
            return 0;
            exit;
          }
        

          $res = $this->update1('tb_checkout_item',$dataItem, ['cl_checkout_id' => $id]);
          if(!$res)
          {
            return 0;
            exit;
          }

            $this->dbh->commit();
            return 1;
            exit;
        }
        catch (PDOException $e) {
            // roll back transaction
            $this->dbh->rollback();
            return 0;
        }  
    }
    
    public function Getdata($id)
    {
        $where['cl_id'] = $id;
        return $this->fetchRow('tb_checkout', $where);
    }

  public function getOrderItemsGeneral($checkoutItemID)
  {
    
    $where[] = $checkoutItemID;
    $sql = ' SELECT ci.*, p.cl_name, p.cl_supplier, p.cl_product_id, p.cl_profit_percentage, p.cl_supplier_price, p.cl_shipping_price, p.cl_digital FROM tb_checkout_item ci INNER JOIN tb_product p ON ci.cl_product_id=p.cl_id WHERE ci.cl_deleted_at IS NULL AND p.cl_type="General" AND ci.cl_checkout_id=? ';
    return $this->callQuery($sql, $where);
  }


  public function getOrderItemsVariable($checkoutItemID)
  {
    
    $where[] = $checkoutItemID;
    $sql = ' SELECT ci.*, p.cl_name, p.cl_supplier, p.cl_product_id, p.cl_profit_percentage, p.cl_supplier_price, p.cl_shipping_price, p.cl_digital, vpf.cl_filter, vpfv.cl_name AS value, GROUP_CONCAT(CONCAT(vpf.cl_filter, "-", vpfv.cl_name)) AS spec FROM tb_checkout_item ci INNER JOIN tb_product p ON ci.cl_product_id=p.cl_id INNER JOIN tb_variable_product vp ON ci.cl_variable_product_id=vp.cl_id INNER JOIN tb_variable_product_attributes vpa ON vp.cl_id=vpa.cl_variable_product_id INNER JOIN tb_variable_product_filter vpf ON vpf.cl_id=vpa.cl_filter_id INNER JOIN tb_variable_product_filter_values vpfv ON vpfv.cl_id=vpa.cl_value_id WHERE ci.cl_deleted_at IS NULL AND p.cl_type="Variable" AND ci.cl_checkout_id=? GROUP BY ci.cl_product_id ';
    return $this->callQuery($sql, $where);
  }

  public function getPickUpPoint($id)
  {
      $sql = ' SELECT * FROM tb_pickup_points WHERE cl_id=? ';
      return $this->callQueryRow($sql, [$id]);
    //return $this->fetchRow('tb_pickup_points', ['cl_id' => $id]);
  }

  

  public function getAllItems($id)
  {
    $where[] = $id;
    $sql = ' SELECT p.cl_name,ci.cl_quantity, ci.cl_amount,p.cl_image, p.cl_image_location FROM  tb_checkout_item ci INNER JOIN tb_product p ON ci.cl_product_id=p.cl_id WHERE ci.cl_checkout_id=? AND ci.cl_deleted_at IS NULL ';
    return $this->callQuery($sql, $where);
  }

}

$dev = new edit_orders();	
$msg="";
if(!isset($_GET['id']))
{
	  header('Location:list.php');
      exit;
}
$id=$_GET['id'];
$res1 = $dev->Getdata($id);
if(!$res1)
{
  exit;
}


$currentStatus = $res1['cl_status'];

if(isset($_POST['data']))
{
	$data=$_POST['data'];
    if(isset($data['sms_send_checkbox']))
    {
        $sms_send_checkbox = $data['sms_send_checkbox'];
        unset($data['sms_send_checkbox']);
    }
	if(trim($data['cl_fname']) == '')
	{
		//$msg.= "Firstname is required<br/>";
	}
      
	if($msg=="")
	{
        $dataItem = array();
        if(trim($data['cl_delivery_date']) != '')
        {
             $dataItem['cl_delivery_date'] = $data['cl_delivery_date'] = date("Y-m-d", strtotime($data['cl_delivery_date']));
            if($res1['cl_checkout_type'] == 'ind')
            {
                $data['cl_warraty_period'] = 730;
                $dataItem['cl_warraty_period'] = 730;
            }
            else
            {
                $data['cl_warraty_period'] = 365;
                $dataItem['cl_warraty_period'] = 365;
            }
        }
        else
        {
            $data['cl_delivery_date'] = null;
            $data['cl_warraty_period'] = 0;

            $dataItem['cl_delivery_date'] = null;
            $dataItem['cl_warraty_period'] = 0;
        }

        if(trim($data['cl_expected_delivery_date']) != '')
        {
            $data['cl_expected_delivery_date'] = date("Y-m-d", strtotime($data['cl_expected_delivery_date']));
        }
        else
        {
            $data['cl_expected_delivery_date'] = null;
        }

		$res = $dev->index($data,$dataItem, $id);
        if($res)
        {
            $currentImage = '';
            $res1 = $dev->Getdata($id);
            //$currentStatus = $res1['cl_status'];

            $items = $dev->getAllItems($id);
            
            
            if($data['cl_status'] == 'Shipped')
            {
                
              
                
                
                $htmlEmailNew = '<!DOCTYPE html>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" lang="en">

<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0"><!--[if mso]>
<xml><w:WordDocument xmlns:w="urn:schemas-microsoft-com:office:word"><w:DontUseAdvancedTypographyReadingMail/></w:WordDocument>
<o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch><o:AllowPNG/></o:OfficeDocumentSettings></xml>
<![endif]--><!--[if !mso]><!-->
	<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;200;300;400;500;600;700;800;900" rel="stylesheet" type="text/css"><!--<![endif]-->
	<style>
		* {
			box-sizing: border-box;
		}

		body {
			margin: 0;
			padding: 0;
		}

		a[x-apple-data-detectors] {
			color: inherit !important;
			text-decoration: inherit !important;
		}

		#MessageViewBody a {
			color: inherit;
			text-decoration: none;
		}

		p {
			line-height: inherit
		}

		.desktop_hide,
		.desktop_hide table {
			mso-hide: all;
			display: none;
			max-height: 0px;
			overflow: hidden;
		}

		.image_block img+div {
			display: none;
		}

		sup,
		sub {
			font-size: 75%;
			line-height: 0;
		}

		@media (max-width:620px) {
			.mobile_hide {
				display: none;
			}

			.row-content {
				width: 100% !important;
			}

			.stack .column {
				width: 100%;
				display: block;
			}

			.mobile_hide {
				min-height: 0;
				max-height: 0;
				max-width: 0;
				overflow: hidden;
				font-size: 0px;
			}

			.desktop_hide,
			.desktop_hide table {
				display: table !important;
				max-height: none !important;
			}

			.row-6 .column-1 .block-1.paragraph_block td.pad>div,
			.row-7 .column-1 .block-1.paragraph_block td.pad>div,
			.row-8 .column-1 .block-2.paragraph_block td.pad>div,
			.row-9 .column-1 .block-1.paragraph_block td.pad>div,
			.row-9 .column-2 .block-1.paragraph_block td.pad>div,
			.row-9 .column-3 .block-1.paragraph_block td.pad>div,
			.row-9 .column-4 .block-1.paragraph_block td.pad>div {
				text-align: left !important;
				font-size: 16px !important;
			}

			.row-6 .column-1 .block-1.paragraph_block td.pad,
			.row-7 .column-1 .block-1.paragraph_block td.pad,
			.row-8 .column-1 .block-2.paragraph_block td.pad,
			.row-8 .column-1 .block-3.divider_block td.pad,
			.row-9 .column-1 .block-1.paragraph_block td.pad,
			.row-9 .column-2 .block-1.paragraph_block td.pad,
			.row-9 .column-3 .block-1.paragraph_block td.pad,
			.row-9 .column-4 .block-1.paragraph_block td.pad {
				padding: 10px !important;
			}

			.row-8 .column-1 .block-3.divider_block .alignment table {
				display: inline-table;
			}

			.row-8 .column-1 .block-3.divider_block .alignment {
				text-align: center !important;
				font-size: 1px;
			}
		}
	</style><!--[if mso ]><style>sup, sub { font-size: 100% !important; } sup { mso-text-raise:10% } sub { mso-text-raise:-10% }</style> <![endif]-->
</head>

<body class="body" style="background-color: #FFFFFF; margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none;">
	<table class="nl-container" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #FFFFFF;">
		<tbody>
			<tr>
				<td>
					<table class="row row-1" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #FFFFFF; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:25px;padding-top:8px;">
																<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad" style="width:100%;padding-right:0px;padding-left:0px;">
																			<div class="alignment" align="center">
																				<div style="max-width: 90px;"><img src="' . MAIN_DOMAIN . '/images/emails/logo.png" style="display: block; height: auto; border: 0; width: 100%;" width="90" alt title height="auto"></div>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-2" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-left:20px;padding-right:20px;width:100%;">
																<div class="alignment" align="center">
																	<div style="max-width: 560px;"><img src="' . MAIN_DOMAIN . '/images/emails/2_stars8.png" style="display: block; height: auto; border: 0; width: 100%;" width="560" alt title height="auto"></div>
																</div>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-3" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table class="heading_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-bottom:7px;text-align:center;">
																<h1 style="margin: 0; color: #222222; direction: ltr; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 28px; font-weight: 700; letter-spacing: normal; line-height: 1.2; text-align: center; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 34px;"><span class="tinyMce-placeholder" style="word-break: break-word;">Jūsu pasūtījums ir izsūtīts!</span></h1>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-4" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:47px;padding-left:22px;padding-right:22px;padding-top:7px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#222222;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;font-size:17px;font-weight:400;letter-spacing:0px;line-height:1.5;text-align:center;mso-line-height-alt:26px;">
																				<p style="margin: 0;">Lieliskas ziņas! Jūsu pasūtījums ir nodots kurjerdienestam un ir ceļā. Jūs varat sekot līdzi sūtījuma statusam izmantojot zemāk norādītos datus.</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-5" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #FFFFFF; vertical-align: top;">
													<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-left:20px;padding-right:20px;width:100%;">
																<div class="alignment" align="center">
																	<div style="max-width: 560px;"><img src="' . MAIN_DOMAIN . '/images/emails/3_email-shipped.png" style="display: block; height: auto; border: 0; width: 100%;" width="560" alt title height="auto"></div>
																</div>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-6" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-top:47px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:left;mso-line-height-alt:19px;">
																				<p style="margin: 0;"><strong>Sūtījuma informācija:</strong></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-7" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:52px;padding-top:10px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad" style="padding-bottom:25px;padding-left:10px;padding-right:10px;padding-top:10px;">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:left;mso-line-height-alt:19px;">
																				<p style="margin: 0; margin-bottom: 16px;"><strong>Piegāde uz</strong>: ' . htmlspecialchars($res1['cl_address']) . '</p>
																				<p style="margin: 0; margin-bottom: 16px;"><strong>Izsekošanas numurs</strong>: <span style="word-break: break-word; color: #ef6c00;">' . htmlspecialchars($res1['cl_tracking_number']) . '</span></p>
																				<p style="margin: 0;"><strong>Kurjerdienests</strong>: <span style="word-break: break-word; color: #ef6c00;">' . htmlspecialchars($res1['cl_courier_provider']) . '</span></p>
																			</div>
																		</td>
																	</tr>
																</table>
																<table class="paragraph_block block-2" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad" style="padding-left:10px;">
																			<div style="color:#222222;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;font-size:15px;font-weight:400;letter-spacing:0px;line-height:1.5;text-align:left;mso-line-height-alt:23px;">
																				<p style="margin: 0;">Ziņas par sūtījuma saņemšanas laiku un tālāko piegādes procesu Jums paziņos kurjerdienests. Aicinām sekot līdzi paziņojumiem savā epastā un īsziņās.</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-8" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-top:10px;">
																<table class="heading_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad" style="padding-bottom:5px;text-align:center;">
																			<h1 style="margin: 0; color: #222222; direction: ltr; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 700; letter-spacing: normal; line-height: 1.2; text-align: center; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 22px;"><span style="word-break: break-word;">Nepieciešama palīdzība?</span></h1>
																		</td>
																	</tr>
																</table>
																<table class="paragraph_block block-2" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad" style="padding-bottom:40px;padding-left:10px;padding-right:10px;padding-top:10px;">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:19px;">
																				<p style="margin: 0;">Atbildiet uz šo e-pastu vai izmantojiet mūsu <a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #101112;" rel="noopener">kontaktu lapu</a>.</p>
																			</div>
																		</td>
																	</tr>
																</table>
																<table class="divider_block block-3" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad">
																			<div class="alignment" align="center">
																				<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																					<tr>
																						<td class="divider_inner" style="font-size: 1px; line-height: 1px; border-top: 1px solid #dddddd;"><span style="word-break: break-word;">&#8202;</span></td>
																					</tr>
																				</table>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-9" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Informācijas centrs</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-2" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Atgriešana</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-3" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/veikals/account/orders" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Mani pasūtījumi</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-4" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Lietošanas noteikumi</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-10" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; background-size: auto;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; background-size: auto; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:20px;padding-left:53px;padding-right:53px;padding-top:20px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;font-size:12px;font-weight:400;letter-spacing:0px;line-height:1.8;text-align:center;mso-line-height-alt:22px;">
																				<p style="margin: 0;">© 2024-2026 SIA EESTI INPOST | uvo.lv</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</tbody>
	</table><!-- End -->
</body>

</html>';
              
                        send_email($res1['cl_email'], 'Uvo', 'Uvo - ' . lang('Products Shipped', $language) . ' 67371-' . $res1['cl_id'], $htmlEmailNew, null, 1, 1);

            }

         else if($data['cl_status'] == 'Delivered')
            {
                $htmlEmail = '<table style="width:100%;max-width:800px;margin:0 auto;font-family:arial;color:#595151">
                            
                            <tr>
                             <td></td>
                                <td style="padding-bottom:25px;text-align:center">
                                    <img style="" src="https://Uvo.lt/uploads/logo/logo.png?version=1019" style="width:60px" />
                                </div>
                                </td>
                                 <td></td>
                            </tr>
                            <tr>
                                <th colspan="3" style="font-size: 35px;padding-bottom:35px;color:black;text-align:center">
                                     #67371-' . $res1['cl_id'] . '  - ' . lang('Please Leave Review', $language) . '
                                </th>
                            </tr>
                            <tr>
                                <th colspan="3" style="text-align:left;font-size: 18px;padding-bottom:15px;color:black;font-weight:bold">
                                    ' . lang('Hello', $language) . ', ' . $res1['cl_fname'] . '!
                                </th>
                            </tr>
                            
                            <tr>
                                <td colspan="3" style="ext-align:left;font-size: 18px;padding-bottom:15px;color:black;font-weight:bold">
                                    ' . lang('Thank you for purchasing', $language) . ' www.Uvo.lt
                                </div>
                            </tr>

                            <tr>
                                <td colspan="3" style="ext-align:left;font-size: 18px;padding-bottom:15px;color:black">
                                    ' . lang('You will help other buyers a lot of sharing their experience and evaluating the purchased goods. It will take no more than a minute of your time', $language) . '.
                                </div>
                            </tr>
                            
                            <tr>
                                <td colspan="3" style="padding-bottom:25px;text-align:center">
                                    <a href="' . MAIN_DOMAIN . '/veikals/account/orders" style="background-color:black;color:white;padding:25px;display:block;text-decoration:none">' . lang('EVALUATE THE GOODS PURCHASED', $language) . '.</a>
                                </td>
                            </tr>

                            <tr>
                                <td colspan="3" style="ext-align:left;font-size: 18px;padding-bottom:15px;color:black">
                                    ' . lang('If you are satisfied with your work of www.Uvo.lt, we will be happy if you leave your positive feedback on www.Uvo.lt', $language) . '.
                                </div>
                            </tr>
                             <tr>
                                <th colspan="3" style="text-align: center;padding-top: 81px;font-size: 18px">
                                  ' . lang('Paldies, ka izvēlējāties Elect.lv', $language) . '!
                                </th>
                              </tr>
                             
                            ';
                            

                            $htmlEmail.= '</table>';
                            
                         

                        //send_email($res1['cl_email'], 'Uvo', 'Uvo - ' . lang('Products Delivered', $language) . ' 67371-' . $res1['cl_id'], $htmlEmail, null, 1, 1);

            }
            
            
           


            if($currentStatus != $data['cl_status'])
            {
                $country = $data['cl_country'];
    
                if($country == 'Latvija')
                {
                    $number = '371';
                }
                else if($country == 'Austria')
                {
                    $number = '43';
                }
                else if($country == 'Italu')
                {
                    $number = '39';
                }
                else if($country == 'Belgium')
                {
                    $number = '32';
                }
                else if($country == 'Bulgaria')
                {
                    $number = '359';
                }
                else if($country == 'Lithuania')
                {
                    $number = '370';
                }
                else if($country == 'Croati')
                {
                    $number = '385';
                }
                else if($country == 'Luxembourg')
                {
                    $number = '352';
                }
                else if($country == 'Cyprus')
                {
                    $number = '357';
                }
                else if($country == 'Malta')
                {
                    $number = '356';
                }
                else if($country == 'Czechia')
                {
                    $number = '420';
                }
                else if($country == 'Netherlands')
                {
                    $number = '31';
                }
                else if($country == 'Denmark')
                {
                    $number = '45';
                }
                else if($country == 'Poland')
                {
                    $number = '48';
                }
                else if($country == 'Estonia')
                {
                    $number = '372';
                }
                else if($country == 'Portugal')
                {
                    $number = '351';
                }
                else if($country == 'Finland')
                {
                    $number = '358';
                }
                else if($country == 'Romania')
                {
                    $number = '40';
                }
                else if($country == 'France')
                {
                    $number = '33';
                }
                else if($country == 'Slovakia')
                {
                    $number = '421';
                }
                else if($country == 'Germany')
                {
                    $number = '49';
                }
                else if($country == 'Slovenia')
                {
                    $number = '386';
                }
                else if($country == 'Greece')
                {
                    $number = '30';
                }
                else if($country == 'Spain')
                {
                    $number = '34';
                }
                else if($country == 'Hungary')
                {
                    $number = '36';
                }
                else if($country == 'Sweden')
                {
                    $number = '46';
                }else if($country == 'Ireland')
                {
                    $number = '353';
                }else if($country == 'United Kingdom')
                {
                    $number = '44';
                }
                else if($country == 'India')
                {
                    $number = '91';
                }

                $message = '';
                $number.= $data['cl_mobile'];

               
                if(isset($sms_send_checkbox) && $sms_send_checkbox == 1)
                {
                    if($data['cl_status'] == 'Delivered')
                    {
                        $message = 'Paldies kad izvēlējies Uvo.LT    Ja esi apmierināts ar mūsu apkalpošanu,mēs būtu ļoti pateicīgi par atsauksmi salīdzini.lv vai facebook lapā.';
                        //    'https://www.salidzini.lv/veikals/elect.lv    https://www.facebook.com/Eretaillv/    Jauku dienu vēlot tavs viedveikals elect.LV';
                    }
                    else if($data['cl_status'] == 'Shipped')
                    {
                         $message = lang('shipped_sms', $language, $id, $data['cl_tracking_number']);
                       // $message = 'Sveiki!    Jūsu Pasūtījums 67371-' . $id . ' ir nodots kurjeram.    Jūsu nosekošanas nr: ' . $data['cl_tracking_number'] . '    Kurjers: ' . $data['cl_courier_provider'] . '    Paldies kad izvēlējies Uvo.LT';
                       
                    }
                    else if($data['cl_status'] == 'Payment Received')
                    {
                        $message = lang('payment_received_sms', $language, $id);
                      //  $message = 'Paldies! Jūsu rēķina 67371-' . $id . ' veiktais maksājums ir saņemts.    Sākam sagatavot jūsu pasūtījumu izsūtīšanai.';
                    }
                    else if($data['cl_status'] == 'Money refunded')
                    {
                        $message = lang('money_refunded_sms', $language, $id);
                       // $message = 'Sveiki! Esam veikuši naudas atmaksu par pasūtījumu 67371-' . $id . '    Jūsu prece vai nu bija brāķis, vai arī tika konstatēti citi tehniski iesmesli.    Vairak informācijas par naudas atmaksas iemeslu Jūs variet uzzināt zvanot mums uz    tālruni: +371 61112470    Jauku dienu vēlot tavs viedveikals.';
                    }
                    else if($data['cl_status'] == 'Items ordered')
                    {
                        $message = 'Sveiki!    Esam pasūtījuši Jūsu 67371-' . $id . ' pasūtījuma preces, un viņas ir ceļā uz mūsu    Latvijas noliktavu.';
                    }
                    else if($data['cl_status'] == 'Items received')
                    {
                        $message = 'Sveiki!    Jūsu pasūtījuma 67371-' . $id . ' preces ir mūsu Latvijas noliktavā.    Jauku dienu vēlot tavs viedveikals     Uvo.LT';
                    }
                    else if($data['cl_status'] == 'Processing')
                    {
                        $message = 'Sākam sagatavot Jūsu pasūtījumu 67371-' . $id . ' nodošanai uz piegādi.    Jauku dienu vēlot Uvo.LT!';
                    }
                    else if($data['cl_status'] == 'Processed')
                    {
                        $message = 'Jūsu pasūtījums 67371-' . $id . ' ir apstrādāts.Un informācija nosūtīta kurjeram.    Tuvākajā laikā Jūsu pasūtījums tiks nodots uz piegādi!    Jauku dienu vēlot tavs viedveikals    Uvo.LT';
                    }
                }

                if(trim($message) != '')
                {
                    file_get_contents('https://api.text2reach.com/sms/send?api_key=127D956CDFD6CD93538A8C9301EB59B8&phone=' . $number . '&from=Uvo.LV&message=' . $message);
                }
                
                
                if($data['cl_status'] == 'Payment Received')
                {
                    
                
                            
                    
                    $htmlEmailPaymentReceived = '<!DOCTYPE html>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" lang="en">

<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0"><!--[if mso]>
<xml><w:WordDocument xmlns:w="urn:schemas-microsoft-com:office:word"><w:DontUseAdvancedTypographyReadingMail/></w:WordDocument>
<o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch><o:AllowPNG/></o:OfficeDocumentSettings></xml>
<![endif]--><!--[if !mso]><!-->
	<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;200;300;400;500;600;700;800;900" rel="stylesheet" type="text/css"><!--<![endif]-->
	<style>
		* {
			box-sizing: border-box;
		}

		body {
			margin: 0;
			padding: 0;
		}

		a[x-apple-data-detectors] {
			color: inherit !important;
			text-decoration: inherit !important;
		}

		#MessageViewBody a {
			color: inherit;
			text-decoration: none;
		}

		p {
			line-height: inherit
		}

		.desktop_hide,
		.desktop_hide table {
			mso-hide: all;
			display: none;
			max-height: 0px;
			overflow: hidden;
		}

		.image_block img+div {
			display: none;
		}

		sup,
		sub {
			font-size: 75%;
			line-height: 0;
		}

		@media (max-width:620px) {
			.row-6 .column-1 .block-1.button_block .alignment .button {
				display: inline-block !important;
			}

			.mobile_hide {
				display: none;
			}

			.row-content {
				width: 100% !important;
			}

			.stack .column {
				width: 100%;
				display: block;
			}

			.mobile_hide {
				min-height: 0;
				max-height: 0;
				max-width: 0;
				overflow: hidden;
				font-size: 0px;
			}

			.desktop_hide,
			.desktop_hide table {
				display: table !important;
				max-height: none !important;
			}

			.row-7 .column-1 .block-1.paragraph_block td.pad>div,
			.row-7 .column-1 .block-2.paragraph_block td.pad>div,
			.row-8 .column-1 .block-2.paragraph_block td.pad>div,
			.row-9 .column-1 .block-1.paragraph_block td.pad>div,
			.row-9 .column-2 .block-1.paragraph_block td.pad>div,
			.row-9 .column-3 .block-1.paragraph_block td.pad>div,
			.row-9 .column-4 .block-1.paragraph_block td.pad>div {
				text-align: left !important;
				font-size: 16px !important;
			}

			.row-6 .column-1 .block-1.button_block td.pad,
			.row-7 .column-1 .block-1.paragraph_block td.pad,
			.row-7 .column-1 .block-2.paragraph_block td.pad,
			.row-8 .column-1 .block-2.paragraph_block td.pad,
			.row-8 .column-1 .block-3.divider_block td.pad,
			.row-9 .column-1 .block-1.paragraph_block td.pad,
			.row-9 .column-2 .block-1.paragraph_block td.pad,
			.row-9 .column-3 .block-1.paragraph_block td.pad,
			.row-9 .column-4 .block-1.paragraph_block td.pad {
				padding: 10px !important;
			}

			.row-6 .column-1 .block-1.button_block span {
				font-size: 16px !important;
				line-height: 32px !important;
			}

			.row-6 .column-1 .block-1.button_block .alignment {
				text-align: center !important;
			}

			.row-8 .column-1 .block-3.divider_block .alignment table {
				display: inline-table;
			}

			.row-8 .column-1 .block-3.divider_block .alignment {
				text-align: center !important;
				font-size: 1px;
			}
		}
	</style><!--[if mso ]><style>sup, sub { font-size: 100% !important; } sup { mso-text-raise:10% } sub { mso-text-raise:-10% }</style> <![endif]-->
</head>

<body class="body" style="background-color: #FFFFFF; margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none;">
	<table class="nl-container" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #FFFFFF;">
		<tbody>
			<tr>
				<td>
					<table class="row row-1" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #FFFFFF; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:25px;padding-top:8px;">
																<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad" style="width:100%;padding-right:0px;padding-left:0px;">
																			<div class="alignment" align="center">
																				<div style="max-width: 90px;"><img src="' . MAIN_DOMAIN . '/images/emails/logo.png" style="display: block; height: auto; border: 0; width: 100%;" width="90" alt title height="auto"></div>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-2" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-left:20px;padding-right:20px;width:100%;">
																<div class="alignment" align="center">
																	<div style="max-width: 560px;"><img src="' . MAIN_DOMAIN . '/images/emails/2_stars8.png" style="display: block; height: auto; border: 0; width: 100%;" width="560" alt title height="auto"></div>
																</div>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-3" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table class="heading_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-bottom:7px;padding-left:60px;padding-right:60px;text-align:center;">
																<h1 style="margin: 0; color: #222222; direction: ltr; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 28px; font-weight: 700; letter-spacing: normal; line-height: 1.2; text-align: center; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 34px;"><span style="word-break: break-word;">Jūsu pasūtījums ir apstrādē!</span></h1>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-4" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:47px;padding-left:22px;padding-right:22px;padding-top:7px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#222222;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;font-size:18px;font-weight:400;letter-spacing:0px;line-height:1.5;text-align:center;mso-line-height-alt:27px;">
																				<p style="margin: 0;">Esam saņēmuši Jūsu maksājumu un uzsākam pasūtījuma apstrādi.&nbsp;</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-5" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #FFFFFF; vertical-align: top;">
													<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-left:20px;padding-right:20px;width:100%;">
																<div class="alignment" align="center">
																	<div style="max-width: 560px;"><img src="' . MAIN_DOMAIN . '/images/emails/3_email-paymentreceived.png" style="display: block; height: auto; border: 0; width: 100%;" width="560" alt title height="auto"></div>
																</div>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-6" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:12px;padding-top:47px;">
																<table class="button_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad">
																			<div class="alignment" align="center"><a href="https://uvo.lv/veikals/account/orders" target="_blank" style="color:#ffffff;text-decoration:none;"><!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"  href="https://uvo.lv/veikals/account/orders"  style="height:42px;width:200px;v-text-anchor:middle;" arcsize="120%" fillcolor="#ef6c00">
<v:stroke dashstyle="Solid" weight="0px" color="#ef6c00"/>
<w:anchorlock/>
<v:textbox inset="0px,0px,0px,0px">
<center dir="false" style="color:#ffffff;font-family:sans-serif;font-size:16px">
<![endif]--><span class="button" style="background-color: #ef6c00; border-bottom: 0px solid transparent; border-left: 0px solid transparent; border-radius: 50px; border-right: 0px solid transparent; border-top: 0px solid transparent; color: #ffffff; display: inline-block; font-family: Arial, Helvetica Neue, Helvetica, sans-serif; font-size: 16px; font-weight: 400; mso-border-alt: none; text-align: center; width: auto; word-break: keep-all; letter-spacing: normal;"><span class="btn-pad" style="word-break: break-word; padding-left: 30px; padding-right: 30px; padding-top: 5px; padding-bottom: 5px; display: block;"><span style="word-break: break-word; line-height: 32px;">Apskatīt pasūtījumu</span></span></span><!--[if mso]></center></v:textbox></v:roundrect><![endif]--></a></div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-7" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:47px;padding-top:10px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:left;mso-line-height-alt:19px;">
																				<p style="margin: 0;"><strong>Pasūtījuma kopsavilkums:</strong></p>
																			</div>
																		</td>
																	</tr>
																</table>
																<table class="paragraph_block block-2" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:left;mso-line-height-alt:19px;">
																				<p style="margin: 0;">';
                                                                                
                                                                                $vatAmount = $res1['cl_vat_amount'];
                              $priceAfterPromoCode = $res1['cl_priceAfterPromoCode'];
                              $vatPercentage = ($vatAmount / $priceAfterPromoCode) * 100;
                              $vatPercentage = round($vatPercentage, 2);

                    
                            foreach($items AS $item)
                            { 
                                if($item['cl_image'] != '')
                                {
                                    if($item['cl_image_location'] == 'Server')
                                    { 
                                        $currentImage = MAIN_DOMAIN . '/uploads/products/' . htmlspecialchars($item['cl_image']);

                                    }
                                    else if($item['cl_image_location'] == 'CDN')
                                    {
                                        $currentImage = 'https://cdn.action.pl/File.aspx?CID=73833&UID=efix2881&PID=ec4549b100d92e60dd4c768ae1e61033&P=' . htmlspecialchars($item['cl_image']); 
                                    }
                                    else
                                    {
                                        $currentImage = $item['cl_image'];
                                    }
                                }
                                
                                
                                
                                /*$finalPrice = $this->helper->getFinalPrice($supplierPrice, $request->profitPercentageArray);
                                $salePrice = $finalPrice;
                                $itemSalePriceWithVAT = $salePrice + ($salePrice * ($request->profitPercentageArray['taxPercentage'] / 100));
                                */
                                
                                $htmlEmailPaymentReceived.= '<tr>
                                 <td align="left" class="esdev-adapt-off" style="Margin:0;padding-top:15px;padding-right:20px;padding-left:20px;padding-bottom:40px">
                                    <table cellpadding="0" cellspacing="0" class="esdev-mso-table" role="none" style="border-collapse:collapse;border-spacing:0px;width:560px">
                                       <tr>
                                          <td valign="top" class="esdev-mso-td" style="padding:0;Margin:0">
                                             <table cellpadding="0" cellspacing="0" align="left" class="es-left" role="none" style="border-collapse:collapse;border-spacing:0px;float:left">
                                                <tr>
                                                   <td align="center" class="es-m-p0r" style="padding:0;Margin:0;width:127px">
                                                      <table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="border-collapse:collapse;border-spacing:0px">
                                                         <tr>
                                                            <td align="center" style="padding:0;Margin:0;font-size:0px"><img src="' . $currentImage . '" alt="" width="69" class="adapt-img" style="display:block;font-size:14px;border:0;outline:none;text-decoration:none"></td>
                                                         </tr>
                                                      </table>
                                                   </td>
                                                </tr>
                                             </table>
                                          </td>
                                          <td class="es-m-w0" style="padding:0;Margin:0;width:20px"></td>
                                          <td valign="top" class="esdev-mso-td" style="padding:0;Margin:0">
                                             <table cellpadding="0" cellspacing="0" align="right" class="es-right" role="none" style="border-collapse:collapse;border-spacing:0px;float:right">
                                                <tr>
                                                   <td align="center" style="padding:0;Margin:0;width:413px">
                                                      <table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="border-collapse:collapse;border-spacing:0px">
                                                         <tr>
                                                            <td align="left" style="padding:0;Margin:0;padding-top:5px">
                                                               <p style="Margin:0;line-height:21px;letter-spacing:0;color:#333333;font-size:14px"><strong> ' . $item['cl_name'] . '<br> </strong></p>
                                                            </td>
                                                         </tr>
                                                         <tr>
                                                            <td align="left" style="padding:0;Margin:0;padding-top:25px">
                                                               <p style="Margin:0;line-height:21px;letter-spacing:0;color:#333333;font-size:14px"><strong>' . lang('Cena', $language) . ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . lang('Daudzums', $language) . '</strong></p>
                                                               <p style="Margin:0;line-height:21px;letter-spacing:0;color:#333333;font-size:14px">€ ' . round($item['cl_amount'] + ($item['cl_amount'] * ($vatPercentage / 100)), 2) . ' &nbsp; &nbsp; &nbsp; &nbsp; ' . $item['cl_quantity'] . '</p>
                                                            </td>
                                                         </tr>
                                                      </table>
                                                   </td>
                                                </tr>
                                             </table>
                                          </td>
                                       </tr>
                                    </table>
                                 </td>
                              </tr>';
                              
                            }

                                                                                $htmlEmailPaymentReceived.= '</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-8" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-top:10px;">
																<table class="heading_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad" style="padding-bottom:5px;text-align:center;">
																			<h1 style="margin: 0; color: #222222; direction: ltr; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 700; letter-spacing: normal; line-height: 1.2; text-align: center; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 22px;"><span style="word-break: break-word;">Nepieciešama palīdzība?</span></h1>
																		</td>
																	</tr>
																</table>
																<table class="paragraph_block block-2" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad" style="padding-bottom:40px;padding-left:10px;padding-right:10px;padding-top:10px;">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:19px;">
																				<p style="margin: 0;">Atbildiet uz šo e-pastu vai izmantojiet mūsu <a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #101112;" rel="noopener">kontaktu lapu</a>.</p>
																			</div>
																		</td>
																	</tr>
																</table>
																<table class="divider_block block-3" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad">
																			<div class="alignment" align="center">
																				<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																					<tr>
																						<td class="divider_inner" style="font-size: 1px; line-height: 1px; border-top: 1px solid #dddddd;"><span style="word-break: break-word;">&#8202;</span></td>
																					</tr>
																				</table>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-9" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Informācijas centrs</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-2" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Atgriešana</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-3" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/veikals/account/orders" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Mani pasūtījumi</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-4" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Lietošanas noteikumi</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-10" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; background-size: auto;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; background-size: auto; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:20px;padding-left:53px;padding-right:53px;padding-top:20px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;font-size:12px;font-weight:400;letter-spacing:0px;line-height:1.8;text-align:center;mso-line-height-alt:22px;">
																				<p style="margin: 0;">© 2024-2026 SIA EESTI INPOST | uvo.lv</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</tbody>
	</table><!-- End -->
</body>

</html>';
                         

                        send_email($res1['cl_email'], 'Uvo', 'Uvo - ' . lang('Payment Confirmed', $language) . ' 67371-' . $res1['cl_id'], $htmlEmailPaymentReceived, null, 1, 1);
                       
               
                
                    }
                else if($data['cl_status'] == 'Being prepared for shipping')
                {
                    
                    $htmlEmailBeingPreparedForShipping = '<!DOCTYPE html>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" lang="en">

<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0"><!--[if mso]>
<xml><w:WordDocument xmlns:w="urn:schemas-microsoft-com:office:word"><w:DontUseAdvancedTypographyReadingMail/></w:WordDocument>
<o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch><o:AllowPNG/></o:OfficeDocumentSettings></xml>
<![endif]--><!--[if !mso]><!-->
	<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;200;300;400;500;600;700;800;900" rel="stylesheet" type="text/css"><!--<![endif]-->
	<style>
		* {
			box-sizing: border-box;
		}

		body {
			margin: 0;
			padding: 0;
		}

		a[x-apple-data-detectors] {
			color: inherit !important;
			text-decoration: inherit !important;
		}

		#MessageViewBody a {
			color: inherit;
			text-decoration: none;
		}

		p {
			line-height: inherit
		}

		.desktop_hide,
		.desktop_hide table {
			mso-hide: all;
			display: none;
			max-height: 0px;
			overflow: hidden;
		}

		.image_block img+div {
			display: none;
		}

		sup,
		sub {
			font-size: 75%;
			line-height: 0;
		}

		@media (max-width:620px) {
			.row-6 .column-1 .block-1.button_block .alignment .button {
				display: inline-block !important;
			}

			.mobile_hide {
				display: none;
			}

			.row-content {
				width: 100% !important;
			}

			.stack .column {
				width: 100%;
				display: block;
			}

			.mobile_hide {
				min-height: 0;
				max-height: 0;
				max-width: 0;
				overflow: hidden;
				font-size: 0px;
			}

			.desktop_hide,
			.desktop_hide table {
				display: table !important;
				max-height: none !important;
			}

			.row-7 .column-1 .block-1.paragraph_block td.pad>div,
			.row-7 .column-1 .block-2.paragraph_block td.pad>div,
			.row-8 .column-1 .block-2.paragraph_block td.pad>div,
			.row-9 .column-1 .block-1.paragraph_block td.pad>div,
			.row-9 .column-2 .block-1.paragraph_block td.pad>div,
			.row-9 .column-3 .block-1.paragraph_block td.pad>div,
			.row-9 .column-4 .block-1.paragraph_block td.pad>div {
				text-align: left !important;
				font-size: 16px !important;
			}

			.row-6 .column-1 .block-1.button_block td.pad,
			.row-7 .column-1 .block-1.paragraph_block td.pad,
			.row-7 .column-1 .block-2.paragraph_block td.pad,
			.row-8 .column-1 .block-2.paragraph_block td.pad,
			.row-8 .column-1 .block-3.divider_block td.pad,
			.row-9 .column-1 .block-1.paragraph_block td.pad,
			.row-9 .column-2 .block-1.paragraph_block td.pad,
			.row-9 .column-3 .block-1.paragraph_block td.pad,
			.row-9 .column-4 .block-1.paragraph_block td.pad {
				padding: 10px !important;
			}

			.row-6 .column-1 .block-1.button_block span {
				font-size: 16px !important;
				line-height: 32px !important;
			}

			.row-6 .column-1 .block-1.button_block .alignment {
				text-align: center !important;
			}

			.row-8 .column-1 .block-3.divider_block .alignment table {
				display: inline-table;
			}

			.row-8 .column-1 .block-3.divider_block .alignment {
				text-align: center !important;
				font-size: 1px;
			}
		}
	</style><!--[if mso ]><style>sup, sub { font-size: 100% !important; } sup { mso-text-raise:10% } sub { mso-text-raise:-10% }</style> <![endif]-->
</head>

<body class="body" style="background-color: #FFFFFF; margin: 0; padding: 0; -webkit-text-size-adjust: none; text-size-adjust: none;">
	<table class="nl-container" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #FFFFFF;">
		<tbody>
			<tr>
				<td>
					<table class="row row-1" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #FFFFFF; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:25px;padding-top:8px;">
																<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad" style="width:100%;padding-right:0px;padding-left:0px;">
																			<div class="alignment" align="center">
																				<div style="max-width: 90px;"><img src="' . MAIN_DOMAIN . '/images/emails/logo.png" style="display: block; height: auto; border: 0; width: 100%;" width="90" alt title height="auto"></div>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-2" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-left:20px;padding-right:20px;width:100%;">
																<div class="alignment" align="center">
																	<div style="max-width: 560px;"><img src="' . MAIN_DOMAIN . '/images/emails/2_stars8.png" style="display: block; height: auto; border: 0; width: 100%;" width="560" alt title height="auto"></div>
																</div>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-3" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table class="heading_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-bottom:7px;text-align:center;">
																<h1 style="margin: 0; color: #222222; direction: ltr; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 28px; font-weight: 700; letter-spacing: normal; line-height: 1.2; text-align: center; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 34px;">Jūsu pasūtījums tiek gatavots sūtīšanai</h1>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-4" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:47px;padding-left:22px;padding-right:22px;padding-top:7px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#222222;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;font-size:18px;font-weight:400;letter-spacing:0px;line-height:1.5;text-align:center;mso-line-height-alt:27px;">
																				<p style="margin: 0;">Esam saņēmuši Jūsu preci, un pasūtījums tiek sagatavots sūtīšanai. Mēs Jūs informēsim, tiklīdz sūtījums tiks nodots piegādes dienestam.</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-5" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #FFFFFF; vertical-align: top;">
													<table class="image_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="pad" style="padding-left:20px;padding-right:20px;width:100%;">
																<div class="alignment" align="center">
																	<div style="max-width: 560px;"><img src="' . MAIN_DOMAIN . '/images/emails/3_email-beingprepared.png" style="display: block; height: auto; border: 0; width: 100%;" width="560" alt title height="auto"></div>
																</div>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-6" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:12px;padding-top:47px;">
																<table class="button_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad">
																			<div class="alignment" align="center"><a href="https://uvo.lv/veikals/account/orders" target="_blank" style="color:#ffffff;text-decoration:none;"><!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"  href="https://uvo.lv/veikals/account/orders"  style="height:42px;width:200px;v-text-anchor:middle;" arcsize="120%" fillcolor="#ef6c00">
<v:stroke dashstyle="Solid" weight="0px" color="#ef6c00"/>
<w:anchorlock/>
<v:textbox inset="0px,0px,0px,0px">
<center dir="false" style="color:#ffffff;font-family:sans-serif;font-size:16px">
<![endif]--><span class="button" style="background-color: #ef6c00; border-bottom: 0px solid transparent; border-left: 0px solid transparent; border-radius: 50px; border-right: 0px solid transparent; border-top: 0px solid transparent; color: #ffffff; display: inline-block; font-family: Arial, Helvetica Neue, Helvetica, sans-serif; font-size: 16px; font-weight: 400; mso-border-alt: none; text-align: center; width: auto; word-break: keep-all; letter-spacing: normal;"><span class="btn-pad" style="word-break: break-word; padding-left: 30px; padding-right: 30px; padding-top: 5px; padding-bottom: 5px; display: block;"><span style="word-break: break-word; line-height: 32px;">Apskatīt pasūtījumu</span></span></span><!--[if mso]></center></v:textbox></v:roundrect><![endif]--></a></div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-7" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:47px;padding-top:10px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:left;mso-line-height-alt:19px;">
																				<p style="margin: 0;"><strong>Pasūtījuma kopsavilkums:</strong></p>
																			</div>
																		</td>
																	</tr>
																</table>
																<table class="paragraph_block block-2" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:left;mso-line-height-alt:19px;">
																				<p style="margin: 0;">';
                                                                                 $vatAmount = $res1['cl_vat_amount'];
                              $priceAfterPromoCode = $res1['cl_priceAfterPromoCode'];
                              $vatPercentage = ($vatAmount / $priceAfterPromoCode) * 100;
                              $vatPercentage = round($vatPercentage, 2);

                    
                            foreach($items AS $item)
                            { 
                                if($item['cl_image'] != '')
                                {
                                    if($item['cl_image_location'] == 'Server')
                                    { 
                                        $currentImage = MAIN_DOMAIN . '/uploads/products/' . htmlspecialchars($item['cl_image']);

                                    }
                                    else if($item['cl_image_location'] == 'CDN')
                                    {
                                        $currentImage = 'https://cdn.action.pl/File.aspx?CID=73833&UID=efix2881&PID=ec4549b100d92e60dd4c768ae1e61033&P=' . htmlspecialchars($item['cl_image']); 
                                    }
                                    else
                                    {
                                        $currentImage = $item['cl_image'];
                                    }
                                }
                                
                                
                                
                                /*$finalPrice = $this->helper->getFinalPrice($supplierPrice, $request->profitPercentageArray);
                                $salePrice = $finalPrice;
                                $itemSalePriceWithVAT = $salePrice + ($salePrice * ($request->profitPercentageArray['taxPercentage'] / 100));
                                */
                                
                                $htmlEmailBeingPreparedForShipping.= '<tr>
                                 <td align="left" class="esdev-adapt-off" style="Margin:0;padding-top:15px;padding-right:20px;padding-left:20px;padding-bottom:40px">
                                    <table cellpadding="0" cellspacing="0" class="esdev-mso-table" role="none" style="border-collapse:collapse;border-spacing:0px;width:560px">
                                       <tr>
                                          <td valign="top" class="esdev-mso-td" style="padding:0;Margin:0">
                                             <table cellpadding="0" cellspacing="0" align="left" class="es-left" role="none" style="border-collapse:collapse;border-spacing:0px;float:left">
                                                <tr>
                                                   <td align="center" class="es-m-p0r" style="padding:0;Margin:0;width:127px">
                                                      <table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="border-collapse:collapse;border-spacing:0px">
                                                         <tr>
                                                            <td align="center" style="padding:0;Margin:0;font-size:0px"><img src="' . $currentImage . '" alt="" width="69" class="adapt-img" style="display:block;font-size:14px;border:0;outline:none;text-decoration:none"></td>
                                                         </tr>
                                                      </table>
                                                   </td>
                                                </tr>
                                             </table>
                                          </td>
                                          <td class="es-m-w0" style="padding:0;Margin:0;width:20px"></td>
                                          <td valign="top" class="esdev-mso-td" style="padding:0;Margin:0">
                                             <table cellpadding="0" cellspacing="0" align="right" class="es-right" role="none" style="border-collapse:collapse;border-spacing:0px;float:right">
                                                <tr>
                                                   <td align="center" style="padding:0;Margin:0;width:413px">
                                                      <table cellpadding="0" cellspacing="0" width="100%" role="presentation" style="border-collapse:collapse;border-spacing:0px">
                                                         <tr>
                                                            <td align="left" style="padding:0;Margin:0;padding-top:5px">
                                                               <p style="Margin:0;line-height:21px;letter-spacing:0;color:#333333;font-size:14px"><strong> ' . $item['cl_name'] . '<br> </strong></p>
                                                            </td>
                                                         </tr>
                                                         <tr>
                                                            <td align="left" style="padding:0;Margin:0;padding-top:25px">
                                                               <p style="Margin:0;line-height:21px;letter-spacing:0;color:#333333;font-size:14px"><strong>' . lang('Cena', $language) . ' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;' . lang('Daudzums', $language) . '</strong></p>
                                                               <p style="Margin:0;line-height:21px;letter-spacing:0;color:#333333;font-size:14px">€ ' . round($item['cl_amount'] + ($item['cl_amount'] * ($vatPercentage / 100)), 2) . ' &nbsp; &nbsp; &nbsp; &nbsp; ' . $item['cl_quantity'] . '</p>
                                                            </td>
                                                         </tr>
                                                      </table>
                                                   </td>
                                                </tr>
                                             </table>
                                          </td>
                                       </tr>
                                    </table>
                                 </td>
                              </tr>';
                              
                            }
                                                                                
                                                                                $htmlEmailBeingPreparedForShipping.='</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-8" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-top:10px;">
																<table class="heading_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad" style="padding-bottom:5px;text-align:center;">
																			<h1 style="margin: 0; color: #222222; direction: ltr; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 700; letter-spacing: normal; line-height: 1.2; text-align: center; margin-top: 0; margin-bottom: 0; mso-line-height-alt: 22px;"><span style="word-break: break-word;">Nepieciešama palīdzība?</span></h1>
																		</td>
																	</tr>
																</table>
																<table class="paragraph_block block-2" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad" style="padding-bottom:40px;padding-left:10px;padding-right:10px;padding-top:10px;">
																			<div style="color:#101112;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:16px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:19px;">
																				<p style="margin: 0;">Atbildiet uz šo e-pastu vai izmantojiet mūsu <a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #101112;" rel="noopener">kontaktu lapu</a>.</p>
																			</div>
																		</td>
																	</tr>
																</table>
																<table class="divider_block block-3" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																	<tr>
																		<td class="pad">
																			<div class="alignment" align="center">
																				<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
																					<tr>
																						<td class="divider_inner" style="font-size: 1px; line-height: 1px; border-top: 1px solid #dddddd;"><span style="word-break: break-word;">&#8202;</span></td>
																					</tr>
																				</table>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-9" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #ffffff; border-radius: 0; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Informācijas centrs</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-2" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Atgriešana</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-3" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/veikals/account/orders" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Mani pasūtījumi</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
												<td class="column column-4" width="25%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:30px;padding-top:15px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="10" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:13px;font-weight:400;letter-spacing:0px;line-height:1.2;text-align:center;mso-line-height-alt:16px;">
																				<p style="margin: 0;"><a href="https://uvo.lv/lv/Kontakti" target="_blank" style="text-decoration: underline; color: #000000;" rel="noopener">Lietošanas noteikumi</a></p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
					<table class="row row-10" align="center" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; background-size: auto;">
						<tbody>
							<tr>
								<td>
									<table class="row-content stack" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #fafafa; background-size: auto; color: #000000; width: 600px; margin: 0 auto;" width="600">
										<tbody>
											<tr>
												<td class="column column-1" width="100%" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; background-color: #00000000; vertical-align: top;">
													<table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt;">
														<tr>
															<td class="col-pad" style="padding-bottom:20px;padding-left:53px;padding-right:53px;padding-top:20px;">
																<table class="paragraph_block block-1" width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; word-break: break-word;">
																	<tr>
																		<td class="pad">
																			<div style="color:#777777;direction:ltr;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;font-size:12px;font-weight:400;letter-spacing:0px;line-height:1.8;text-align:center;mso-line-height-alt:22px;">
																				<p style="margin: 0;">© 2024-2026 SIA EESTI INPOST | uvo.lv</p>
																			</div>
																		</td>
																	</tr>
																</table>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
		</tbody>
	</table><!-- End -->
</body>

</html>';

  send_email($res1['cl_email'], 'Uvo', 'Uvo - ' . lang('Being prepared for shipping', $language) . ' 67371-' . $res1['cl_id'], $htmlEmailBeingPreparedForShipping, null, 1, 1);
                }
            }
            

            if(!isset($_POST['reload']))
            {
                header('Location:list.php?message=Updated Successfully');
                exit;
            }

            $msg = 'User Order Updated Successfully';
            
        }
        else {
            $msg = 'Something Went Wrong';
        }
	}
}

$templateType = 'edit';
$res1 = $dev->Getdata($id);
$items = $dev->getOrderItemsGeneral($id);
$itemsVariable = $dev->getOrderItemsVariable($id);

$pickUpPointID = $res1['cl_pickup_point'];
if($pickUpPointID != 0)
{
    $pickuPoint = $dev->getPickUpPoint($pickUpPointID);
   
}


include '../header.php';
?>
<link rel="stylesheet" href="../jquery_file_upload/css/style.css">
<link rel="stylesheet" href="../jquery_file_upload/css/jquery.fileupload.css">
            <!-- MAIN CONTENT-->
            <div class="main-content">
                <div class="section__content section__content--p30">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="overview-wrap">
                                    <h2 class="title-1">
                                        Edit Order
                                        <button type="button" class="btn btn-danger" id="order_email_again">Send Order Email Again</button>
                                         <button type="button" class="btn btn-success" id="invoice_create">Create Invoice Only</button>
                                         <a class="btn btn-primary" href="#amount_quantity_edit">Edit Amount and Quantity</a>

                                         <?php
                                         if($res1['cl_courier_provider'] == 'DPD' && trim($res1['cl_tracking_number']) == '')
                                            { ?>
                                         <button type="button" class="btn btn-info" id="label_create">Create Shipping Label</button>
                                         <?php
                                     }
                                     else if($res1['cl_courier_provider'] == 'DPD')
                                     {
                                        ?>
                                         <div class="alert alert-warning">Shipping Label created already. If you want to create new, clear existing tracking id, and save.</div>
                                         <?php
                                     }
                                     ?>


                                        <div class="order_email_error"></div>
                                    </h2>
                                    
                                </div>
								<?php if($msg !=''){echo '<span class="col-md-6 alert alert-danger pull-left">'.$msg.'</span>';}?>
                            </div>
                        </div>
                        
                        <div class="row m-t-25 m-row">
					
                            <div class="col-md-6 col-xs-12">
                                <div class="card">
                                    
                                    <div class="card-body card-block">
									<form method="post" accept-charset="UTF-8">
                                        <div class="form-group">
                                           
                                            <label for="Firstname" class=" form-control-label">Firstname</label>
                                            <input type="text" name="data[cl_fname]" id="Firstname" placeholder="Firstname" class="form-control" value="<?php echo htmlspecialchars($res1['cl_fname']);?>"/>
                                        </div>
                                        <div class="form-group">
                                            <label for="Surname" class=" form-control-label">Surname</label>
                                            <input type="text" name="data[cl_surname]" id="Surname" placeholder="Surname" class="form-control" value="<?php echo htmlspecialchars($res1['cl_surname']);?>"/>
                                        </div>
                                        <div class="form-group">
                                            <label for="Mobile" class=" form-control-label">Mobile</label>
                                            <input type="text" name="data[cl_mobile]" id="Mobile" placeholder="Mobile" class="form-control" value="<?php echo htmlspecialchars($res1['cl_mobile']);?>"/>
                                        </div>
                                         <div class="form-group">
                                               <label for="email" class=" form-control-label">Email</label>
                                             <input type="text" class="form-control" name="data[cl_email]" id="email" placeholder="E-mail" value="<?php echo htmlspecialchars($res1['cl_email']);?>">
                                        </div>
                                        <div class="form-group">
                                               <label for="address" class=" form-control-label">Address</label>
                                             <input type="text" class="form-control" name="data[cl_address]" id="address" placeholder="Address" value="<?php echo htmlspecialchars($res1['cl_address']);?>">
                                        </div>
                                         <div class="form-group">
                                               <label for="city" class=" form-control-label">City</label>
                                             <input type="text" class="form-control" name="data[cl_city]" id="city" placeholder="City" value="<?php echo htmlspecialchars($res1['cl_city']);?>">
                                        </div>
                                         <div class="form-group">
                                               <label for="country" class=" form-control-label">County</label>
                                             <input type="text" class="form-control" name="data[cl_country]" id="country" placeholder="Country" value="<?php echo htmlspecialchars($res1['cl_country']);?>">
                                        </div>
                                        <div class="form-group">
                                               <label for="pasta_indeks" class=" form-control-label">Pasta Indeks</label>
                                             <input type="text" class="form-control" name="data[cl_pasta_indeks]" id="pasta_indeks" placeholder="pasta_indeks" value="<?php echo htmlspecialchars($res1['cl_pasta_indeks']);?>">
                                        </div>
                                         <div class="form-group">
                                               <label for="status" class=" form-control-label">Order Status</label>
                                             <select type="text" class="form-control" name="data[cl_status]" id="status">
                                                 <option value="Processing" <?php if($res1['cl_status'] == 'Processing'){echo 'selected';} ?>>Processing</option>
                                                 <option value="Processing2" <?php if($res1['cl_status'] == 'Processing2'){echo 'selected';} ?>>Processing2</option>
                                                 <option value="Processing3" <?php if($res1['cl_status'] == 'Processing3'){echo 'selected';} ?>>Processing3</option>
                                                 <option value="Processing4" <?php if($res1['cl_status'] == 'Processing4'){echo 'selected';} ?>>Processing4</option>
                                                 <option value="Processed" <?php if($res1['cl_status'] == 'Processed'){echo 'selected';} ?>>Processed</option>
                                                 <option value="Processed2" <?php if($res1['cl_status'] == 'Processed2'){echo 'selected';} ?>>Processed2</option>
                                                 <option value="Processed3" <?php if($res1['cl_status'] == 'Processed3'){echo 'selected';} ?>>Processed3</option>
                                                 <option value="Processed7" <?php if($res1['cl_status'] == 'Processed7'){echo 'selected';} ?>>Processed7</option>
                                                 <option value="Processed8" <?php if($res1['cl_status'] == 'Processed8'){echo 'selected';} ?>>Processed8</option>
                                                 <option value="Waiting on payment" <?php if($res1['cl_status'] == 'Waiting on payment'){echo 'selected';} ?>>Waiting on payment</option>
                                                 <option value="Payment Received" <?php if($res1['cl_status'] == 'Payment Received'){echo 'selected';} ?>>Payment Received</option>
                                                 <option value="Being prepared for shipping" <?php if($res1['cl_status'] == 'Being prepared for shipping'){echo 'selected';} ?>>Being prepared for shipping</option>
                                                  <option value="Being prepared for shipping2" <?php if($res1['cl_status'] == 'Being prepared for shipping2'){echo 'selected';} ?>>Being prepared for shipping2</option>
                                                   <option value="Being prepared for shipping3" <?php if($res1['cl_status'] == 'Being prepared for shipping3'){echo 'selected';} ?>>Being prepared for shipping3</option>
                                                 <option value="Shipped" <?php if($res1['cl_status'] == 'Shipped'){echo 'selected';} ?>>Shipped</option>
                                                 <option value="Delivered" <?php if($res1['cl_status'] == 'Delivered'){echo 'selected';} ?>>Delivered</option>
                                                  <option value="Cancelled"<?php if($res1['cl_status'] == 'Cancelled'){echo 'selected';} ?>>Cancelled</option>
                                                  <option value="Items ordered" <?php if($res1['cl_status'] == 'Items ordered'){echo 'selected';} ?>>Items ordered</option>
                                                  <option value="Items received"<?php if($res1['cl_status'] == 'Items received'){echo 'selected';} ?>>Items received</option>
                                                  <option value="Money refunded" <?php if($res1['cl_status'] == 'Money refunded'){echo 'selected';} ?>>Money refunded</option>
                                                  <option value="Money requested" <?php if($res1['cl_status'] == 'Money requested'){echo 'selected';} ?>>Money requested</option>
                                             </select> 
                                        </div>

                                        <div class="form-group">
                                            <input type="checkbox" checked="checked" name="data[sms_send_checkbox]" value="1" /> Send sms if status changed 
                                        </div>
                                        <div class="form-group">
                                               <label for="company_name" class=" form-control-label">Expected Delivery Date</label>
                                             <input type="text" class="form-control datepicker" name="data[cl_expected_delivery_date]" id="expected_delivery_date" placeholder="Expected Delivery Date" value="<?php if(trim($res1['cl_expected_delivery_date']) != ''){echo htmlspecialchars(date("d M Y", strtotime($res1['cl_expected_delivery_date'])));}?>">
                                        </div>
                                        <div class="form-group">
                                               <label for="company_name" class=" form-control-label">Delivery Date</label>
                                             <input type="text" class="form-control datepicker" name="data[cl_delivery_date]" id="delivery_date" placeholder="Delivery Date" value="<?php if(trim($res1['cl_delivery_date']) != ''){echo htmlspecialchars(date("d M Y", strtotime($res1['cl_delivery_date'])));}?>">
                                        </div>
                                         <div class="form-group">
                                               <label for="courier_provider" class=" form-control-label">Courier Provider</label>
                                             <input type="text" class="form-control" name="data[cl_courier_provider]" id="courier_provider" placeholder="courier provider" value="<?php echo htmlspecialchars($res1['cl_courier_provider']);?>">
                                        </div>
                                         <div class="form-group">
                                               <label for="tracking_number" class=" form-control-label">Tracking Number</label>
                                             <input type="text" class="form-control" name="data[cl_tracking_number]" id="tracking_number" placeholder="tracking number" value="<?php echo htmlspecialchars($res1['cl_tracking_number']);?>">
                                        </div>
                                        <div class="form-group">
                                               <label for="checkout_type" class=" form-control-label">Checkout Type</label>
                                             <select type="text" class="form-control" name="data[cl_checkout_type]" id="checkout_type">
                                                 <option value="ind" <?php if($res1['cl_checkout_type'] == 'ind'){echo 'selected';} ?>>Individual</option>
                                                 <option value="com"<?php if($res1['cl_checkout_type'] == 'com'){echo 'selected';} ?>>Company</option>
                                                
                                             </select> 
                                        </div>
                                        
                                        <div class="form-group">
                                               <label for="company_name" class=" form-control-label">Company Name</label>
                                             <input type="text" class="form-control" name="data[cl_company_name]" id="company_name" placeholder="company name" value="<?php echo htmlspecialchars($res1['cl_company_name']);?>">
                                        </div>
                                        <div class="form-group">
                                               <label for="registration_number" class=" form-control-label">Registration Number</label>
                                             <input type="text" class="form-control" name="data[cl_registration_number]" id="registration_number" placeholder="registration number" value="<?php echo htmlspecialchars($res1['cl_registration_number']);?>">
                                        </div>
                                        <div class="form-group">
                                               <label for="vat_number" class=" form-control-label">VAT Number</label>
                                             <input type="text" class="form-control" name="data[cl_vat_number]" id="vat_number" placeholder="vat number" value="<?php echo htmlspecialchars($res1['cl_vat_number']);?>">
                                        </div>
                                        <div class="form-group">
                                               <label for="vat_number" class=" form-control-label">Amount Calculation</label>
                                             <select class="form-control" name="data[cl_price_calculation]" id="price_calculation" placeholder="Price Calculation" value="<?php echo htmlspecialchars($res1['cl_vat_number']);?>">
                                                 <option value="Automatic" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'selected';} ?>>Automatic</option>
                                                 <option value="Manual" <?php if($res1['cl_price_calculation'] == 'Manual'){echo 'selected';} ?>>Manual</option>
                                             </select>
                                        </div>
                                         <div class="form-group">
                                               <label for="notes" class=" form-control-label">Notes</label>
                                             <textarea class="form-control" name="data[cl_notes]" id="notes" placeholder="Notes" style="height:250px"> <?php echo htmlspecialchars($res1['cl_notes']);?></textarea>
                                        </div>
                                        <div class="form-group input-container">
                                            <label for="file" class=" form-control-label">Invoice</label>
                                                <input type="hidden" class="image" name="data[cl_invoice_doc]" value="<?php if(isset($res1['cl_invoice_doc'])){echo $res1['cl_invoice_doc'];}?>"/>
                                                <input type="hidden" class="name"   />
                                                    <!-- The container for the uploaded files -->
                                                    <span class="btn btn-success fileinput-button">
                                                    <i class="glyphicon glyphicon-plus"></i>
                                                    <span>Select file</span>
                                                    <!-- The file input field used as target for the file upload widget -->
                                                    <input class="fileupload" type="file" name="file" >
                                                    </span>
                                                    <br>
                                                <br>
                                                <!-- The global progress bar -->
                                                <div class="progress">
                                                    <div class="progress-bar progress-bar-success"></div>
                                                </div>
                                                <!-- The container for the uploaded files -->
                                              <?php
                                                  if($templateType == 'edit')
                                    {
                                        $current='<div class="col-xs-12 col-sm-12"><span class="files_area">Current Invoice (Manual): <a target="_blank" class="" href="../uploads/invoice/' . $res1['cl_invoice_doc'].'">Download</a></span></div>';

                                        $current.= '<div class="col-xs-12 col-sm-12"><span class="files_area">Current Invoice (Automatic): <a target="_blank" class="" href="' . MAIN_DOMAIN . '/uploads/invoice/' . $res1['cl_auto_invoice_doc'].'">Download</a></span></div>';
                                    }
                                    else
                                    {
                                        $current='';
                                    }
                                    ?>
                                            <?php echo $current;?>
                                                <div class="file_name">
                                                        
                                                    </div>
                                                 <div class="error_area"></div>

                                            <div class="error-input"></div>
                                        </div>

                                         <div class="form-group input-container">
                                            <label for="file" class=" form-control-label">Warranty Card</label>
                                                <input type="hidden" class="image" name="data[cl_warranty_card]" value="<?php if(isset($res1['cl_warranty_card'])){echo $res1['cl_warranty_card'];}?>"/>
                                                <input type="hidden" class="name"   />
                                                    <!-- The container for the uploaded files -->
                                                    <span class="btn btn-success fileinput-button">
                                                    <i class="glyphicon glyphicon-plus"></i>
                                                    <span>Select file</span>
                                                    <!-- The file input field used as target for the file upload widget -->
                                                    <input class="fileuploadWarrantyCard" type="file" name="file" >
                                                    </span>
                                                    <br>
                                                <br>
                                                <!-- The global progress bar -->
                                                <div class="progress">
                                                    <div class="progress-bar progress-bar-success"></div>
                                                </div>
                                                <!-- The container for the uploaded files -->
                                              <?php
                                                  if($templateType == 'edit')
                                    {
                                        $current='<span class="files_area">Current Warranty Card : <a target="_blank" class="" href="../uploads/warranty_card/' . $res1['cl_warranty_card'].'">Download</a></span>';
                                    }
                                    else
                                    {
                                        $current='';
                                    }
                                    ?>
                                            <?php echo $current;?>
                                                <div class="file_name">
                                                        
                                                    </div>
                                                 <div class="error_area"></div>

                                            <div class="error-input"></div>
                                        </div>
                                        
										<div class="form-group">
                      <div class="btn-container col-xs-12 col-sm-12 pull-left">
                         <button type="submit" class="track-btn pull-right">Submit</button>
                          <button type="submit" class="track-btn pull-right" name="reload">Submit And Reload Page</button>
                      </div>

                      </div>
                  </div>
              </form>
          </div>
      </div>
   




                             

                             <div class="col-md-6 col-xs-12">
                                        <div class="card">
                                            <div class="card-body card-block">
                                                <div class="col-sm-12 col-xs-12 pull-left">
                                                    <h5 class="small-heading py-4">Pasūtītāja dati</h5>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Type</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_checkout_type']);?> </p>
                                                        </div>
                                                    </div>
                                                    <?php
                                                    if($res1['cl_checkout_type'] == 'ind')
                                                        { ?>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Vārds</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_fname']);?> </p>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Uzvārds</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_surname']);?> </p>
                                                        </div>
                                                    </div>
                                                    <?php
                                                }
                                                else
                                                {
                                                ?>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Company Name</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_company_name']);?> </p>
                                                        </div>
                                                    </div>

                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Registration Number</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_registration_number']);?> </p>
                                                        </div>
                                                    </div>

                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>VAT Number</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_vat_number']);?> </p>
                                                        </div>
                                                    </div>

                                                <?php
                                            }
                                            ?>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Kontakttālrunis</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_mobile']);?></p>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>E-pasts</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_email']);?></p>
                                                        </div>
                                                    </div>
                                                </div>

                                                <div class="col-md-12 pull-left">
                                                    <h5 class="small-heading py-4">Piegādes adrese</h5>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Pilsēta</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_city']);?> </p>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Novads</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_country']);?></p>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Adrese</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_address']);?><br/>
                                                            <?php echo htmlspecialchars($res1['cl_pin']);?>
                                                            </p>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>Pasta indeks</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_pasta_indeks']);?> </p>
                                                        </div>
                                                    </div>
                                                    <div class="row">
                                                        <div class="col-md-4">
                                                            <p><strong>IP</strong></p>
                                                        </div>
                                                        <div class="col-md-8">
                                                            <p><?php echo htmlspecialchars($res1['cl_ip']);?> </p>
                                                        </div>
                                                    </div>
                                                </div>  

                                                <div class="col-md-12 col-xs-12 pull-left no-padding">
                                                    
                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Delivery Type</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($res1['cl_delivery_type']);?> </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Payment Type</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($res1['cl_payment_type']);?> </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Payment Reference</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($res1['cl_payment_reference']);?> </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Courier Provider</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($res1['cl_courier_provider']);?> </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Tracking Number</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($res1['cl_tracking_number']);?> </p>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Shipping Method</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($res1['cl_shipping_method']);?> </p>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <?php
                                                    if(isset($pickuPoint))
                                                    {

                                                        ?>
                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Pickup Point</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($pickuPoint['cl_name']);?><br/>
                                                                    <?php echo htmlspecialchars($pickuPoint['cl_address1']);?><br/>
                                                                    <?php echo htmlspecialchars($pickuPoint['cl_address2']);?><br/>
                                                                    <?php echo htmlspecialchars($pickuPoint['cl_city']);?><br/>
                                                                    ZIP : <?php echo htmlspecialchars($pickuPoint['cl_postcode']);?><br/>
                                                                    Country : <?php echo htmlspecialchars($pickuPoint['cl_country']);?><br/>
                                                                    Courier Provider : <?php echo htmlspecialchars($pickuPoint['cl_courier_provider']);?><br/>

                                                                     </p>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <?php 
                                                }
                                                ?>


                                                    

                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                        <div class="col-md-4">
                                                                <p><strong>Status</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo htmlspecialchars($res1['cl_status']);?> </p>
                                                            </div>
                                                        </div>
                                                    </div>
                                                   
                                                   

                                                    <div class="col-sm-12 pull-left">
                                                        <div class="row">
                                                            <div class="col-md-4">
                                                                <p><strong>Created On</strong></p>
                                                            </div>
                                                            <div class="col-md-8">
                                                                <p><?php echo date("d M Y H:i:s", strtotime($res1['cl_created_at']));?> </p>
                                                            </div>
                                                        </div>
                                                    </div>  
                                                
                                                   
                                     
                                            </div>

                                            <?php 
                                if($res1['cl_payment_type'] == 'Loan')
                                { ?>
                                <div class="well-white col-sm-12 col-xs-12 no-padding">
                                    <h5 class="small-heading col-sm-12 py-4">Līzings</h5>
                                    
                                    <div class="col-md-12 pull-left">
                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Down Payment</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_down_payment']);?> </p>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Number of Payment Terms</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_payment_terms']);?> </p>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Vārds</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_fname']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Uzvārds</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_surname']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Persons kods</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_kods']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Pases numurs</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_id_card']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Loan Expiration Date</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars(date("d M Y", strtotime($res1['cl_loan_expiration_date'])));?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>City / Parish / State</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_city_state']);?> </p>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Street / Village</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_street_village']);?> </p>
                                            </div>
                                        </div>

                                    </div>
                                    <div class="col-md-12 pull-left">

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Apartment Number</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_apartment_number']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Pasta Index</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_pasta_index']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Phone</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_phone']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Additional Phone</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_additional_phone']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Workplace</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_workplace']);?> </p>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Periods Worked</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_periods_worked']);?> </p>
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Amats</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_amats']);?> </p>
                                            </div>
                                        </div>
                                        
                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Alga</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_alga']);?> </p>
                                            </div>
                                        </div>
                                        
                                        <div class="row">
                                            <div class="col-md-4">
                                                <p><strong>Existing Loan</strong></p>
                                            </div>
                                            <div class="col-md-8">
                                                <p><?php echo htmlspecialchars($res1['cl_loan_existing_loan']);?> </p>
                                            </div>
                                        </div>
                                        
                                        
                                        <div class="row mt-4">
                                            <div class="col-md-8">
                                                <p><strong>Aizņēmējs: Vai Jūs esat politiski nozīmīga persona, politiski nozīmīgas personas ģimenes loceklis vai ar politiski nozīmīgu personu cieši saistīta persona?</strong></p>
                                            </div>
                                            <div class="col-md-4">
                                                <p>
                                                <?php
                                                if($res1['cl_loan_1_checkbox'] == 1)
                                                {
                                                    echo 'Yes';
                                                }
                                                else
                                                {
                                                    echo 'No';
                                                }
                                                ?>
                                                </p>
                                            </div>
                                        </div>
                                        
                                        <div class="row mt-4">
                                            <div class="col-md-8">
                                                <p><strong>Vai Jūs esat patiesais labuma guvējs plānotā darījuma?</strong></p>
                                            </div>
                                            <div class="col-md-4">
                                                <p>
                                                <?php
                                                if($res1['cl_loan_2_checkbox'] == 1)
                                                {
                                                    echo 'Yes';
                                                }
                                                else
                                                {
                                                    echo 'No';
                                                }
                                                ?>
                                                </p>
                                            </div>
                                        </div>
                                        
                                        
                                        <div class="row mt-4">
                                            <div class="col-md-8">
                                                <p><strong>AS "LATEKO LĪZINGS", reģistrācijas nr. 40003366651, Katlakalna ielā 1, Rīgā, LV-1073 kā pārzinis saņem un apstrādā manus personas datus kredītspējas izvērtēšanai pirms līguma noslēgšanas. Pārzinis kredītspējas izvērtēšanai saņem informāciju par mani no trešām personām (AS "CREFO Birojs", AS Kredītinformācijas Birojs, Iedzīvotāju reģistrs, Valsts ieņēmumu dienests un no citām bāzēm un reģistriem, ar kuriem uz šī pieteikuma iesniegšanas brīdi AS „LATEKO LĪZINGS” tiek noslēgts līgums).<br/>
Ar informāciju par personas datu apstrādes politiku, kuru īsteno AS „LATEKO LĪZINGS”, var iepazīties <a href="https://latekolizings.lv/lv/privatuma-atruna" target="_blank">https://latekolizings.lv/lv/privatuma-atruna</a></strong></p>
                                            </div>
                                            <div class="col-md-4">
                                                <p>
                                                <?php
                                                if($res1['cl_loan_3_checkbox'] == 1)
                                                {
                                                    echo 'Yes';
                                                }
                                                else
                                                {
                                                    echo 'No';
                                                }
                                                ?>
                                                </p>
                                            </div>
                                        </div>

                                        
                                    </div>
                                  
                                    
                                </div>
                                <?php
                                }
                                ?>

                                
                                        </div>

                                         <div class="card top-margin">
                                            <div class="card-body card-block">
                                                <div class="table-responsive table--no-card m-b-30 top-margin pull-left">
                                    
                                                    <table class="table table-borderless table-data3 ACP_table" style="width:100%">
                                                        <thead>
                                                            <tr>
                                                                <th colspan="6" style="text-align: left;">
                                                                    General
                                                                </th>
                                                            </tr>
                                                            <tr>
                                                                <th>Product Name</th>
                                                               
                                                                <th>Supplier</th>
                                                                <th>Product ID</th>

                                                                <th>Sale Price</th>
                                                                <th>Quantity</th>
                                                                <th>Total</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                           <?php
                                                           $total = 0;

                                                            foreach($items AS $orders)
                                                            {
                                                                
                                                                //$product = $obj->getProduct($orders['cl_product_id']);
                                                            
                                                                //$product = $product[0];
                                                                //if($product)
                                                                //{
                                                            ?>
                                                                <tr class="action-container">
                                                                    <td><?php echo htmlspecialchars($orders['cl_name']);?></td>
                                                                    <td><?php echo htmlspecialchars($orders['cl_supplier']);?></td>
                                                                    <td><?php echo htmlspecialchars($orders['cl_product_id']);?></td>
                                                                    
                                                                    
                                                                    <td>$<?php echo htmlspecialchars($orders['cl_amount']) / htmlspecialchars($orders['cl_quantity']);?></td>
                                                                    <td> <?php echo htmlspecialchars($orders['cl_quantity']);?></td>
                                                                    <td>$<?php echo htmlspecialchars($orders['cl_amount']);?></td>
                                                                    <?php $total+= $orders['cl_amount'] ?>
                                                                    
                                                                </tr>
                                                            <?php
                                                        //}
                                                            }
                                                            ?>
                                                           
                                                        </tbody>
                                                        <tfoot>
                                                            
                                                            <tr>
                                                                <td colspan="6" style="text-align: right">
                                                                    Final Total : $<?php echo $res1['cl_total'] ?>
                                                                </td>
                                                            </tr>
                                                        </tfoot>
                                                    </table>

                                                    <table class="table table-borderless table-data3 ACP_table" style="width:100%">
                                                        <thead>
                                                            <tr>
                                                                <th colspan="7" style="text-align: left;">
                                                                    Varaible
                                                                </th>
                                                            </tr>
                                                            <tr>
                                                                <th>Product Name</th>
                                                                <th>Specifications</th>
                                                                <th>Supplier</th>
                                                                <th>Product ID</th>

                                                                <th>Sale Price</th>
                                                                <th>Quantity</th>
                                                                <th>Total</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                           <?php
                                                           $total = 0;

                                                            foreach($itemsVariable AS $orders)
                                                            {
                                                                
                                                                //$product = $obj->getProduct($orders['cl_product_id']);
                                                            
                                                                //$product = $product[0];
                                                                //if($product)
                                                                //{
                                                            ?>
                                                                <tr class="action-container">
                                                                    <td><?php echo htmlspecialchars($orders['cl_name']);?></td>
                                                                    <td><?php echo htmlspecialchars($orders['spec']);?> </td>
                                                                    <td><?php echo htmlspecialchars($orders['cl_supplier']);?></td>
                                                                    <td><?php echo htmlspecialchars($orders['cl_product_id']);?></td>
                                                                    
                                                                    
                                                                    <td>$<?php echo htmlspecialchars($orders['cl_amount']) / htmlspecialchars($orders['cl_quantity']);?></td>
                                                                    <td> <?php echo htmlspecialchars($orders['cl_quantity']);?></td>
                                                                    <td>$<?php echo htmlspecialchars($orders['cl_amount']);?></td>
                                                                    <?php $total+= $orders['cl_amount'] ?>
                                                                    
                                                                </tr>
                                                            <?php
                                                        //}
                                                            }
                                                            ?>
                                                           
                                                        </tbody>
                                                        <tfoot>
                                                            
                                                            <tr>
                                                                <td colspan="6" style="text-align: right">
                                                                    Final Total : $<?php echo $res1['cl_total'] ?>
                                                                </td>
                                                            </tr>
                                                        </tfoot>
                                                    </table>

                                                    
                                                    
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                          
                        </div>



                        <?php
                        if($groupArray['short'] == 'ADM')
                        { ?>
<div class="col-xs-12 col-sm-12" id="amount_quantity_edit">
                        <div class="card">
                                    
                                    <div class="card-body card-block">               

<div class="col-xs-12 col-sm-12 pull-left">
  <table class="table table-bordered ACP_table" style="width:100%">

    <thead>
      <tr>
        <th colspan="6"> 
          Existing Items
        </th>
      </tr>
      <tr>
        <th>
          Item
        </th>
        <th>
          Quantity
        </th>
        <th>
          Amount
        </th>
       <th>
        Digital
       </th>
       <th>
        Code
       </th>
        <th>

        </th>
      </tr>
    </thead>
    <tbody>
      <?php
       $pvn = 0;
       $total = 0;
        if(!empty($items))
        {
          foreach($items AS $item)
          {

             if($item['cl_supplier_price'] < 20)
                {
                    $profitPercentage = $profitPercentage0_20;
                }
                else if($item['cl_supplier_price'] >= 20 && $item['cl_supplier_price'] <= 50)
                {
                    $profitPercentage = $profitPercentage20_50;
                }
                else if($item['cl_supplier_price'] >= 50 && $item['cl_supplier_price'] <= 100)
                {
                    $profitPercentage = $profitPercentage50_100;
                }
                else if($item['cl_supplier_price'] >= 100 && $item['cl_supplier_price'] <= 200)
                {
                    $profitPercentage = $profitPercentage100_200;
                }
             else if($item['cl_supplier_price'] >= 200 && $item['cl_supplier_price'] <= 800)
              {
                $profitPercentage = $profitPercentage200_800;
              }
              else
              {
                $profitPercentage = $profitPercentageMoreThan800;
              }

               $salePrice = $item['cl_supplier_price'] + ($item['cl_supplier_price'] * $profitPercentage / 100);
            ?>
            <tr cluster-id="<?php echo $item['cl_id'] ?>">
              <td>
                <?php echo htmlspecialchars($item['cl_name']) ?>
              </td>
              <td>
               <input type="text" class="form-control item_quantity item_field" name="quantity" value="<?php echo htmlspecialchars($item['cl_quantity']) ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                <div class="error_input"></div>
              </td>
              <td>
                <input type="text" class="form-control item_amount item_field" name="amount" value="<?php echo htmlspecialchars($item['cl_amount']) ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                 <div class="error_input"></div>
              </td>

              <td>
                <?php
                if($item['cl_digital'] == 1)
                {
                    echo 'Yes';
                }
                else
                {
                    echo 'No';
                }
                ?>
              </td>

              <td>
                <input type="text" class="form-control item_code" name="code" value="<?php echo htmlspecialchars($item['cl_code']) ?>"  />
                 <div class="error_input"></div>
              </td>
            
              <td>
               
                <button type="button" class="btn btn-xs btn-danger btn-delete-existing" cluster-id="<?php echo htmlspecialchars($item['cl_id']) ?>"><i class="fa fa-trash"></i></button>
                <div class="delete_error"></div>
              </td>
            </tr>
            <?php

            $total+= $item['cl_amount'];

            if($pvn < $item['cl_shipping_price'])
             {
                $pvn = $item['cl_shipping_price'];
             }
          }
        }

        $pvn = $pvn + ($pvn * $taxPercentage / 100);
                                      //  $pvn = 4.12;
        $grandtotal = $total + $pvn;
      ?>
    </tbody>
  </table>

   

  <table class="table table-bordered top-margin" style="width:100%;margin-top: 15px" id="new_order_items">

    <thead>
      <tr>
        <th colspan="4"> 
          New Items
          <button type="button" class="btn btn-danger pull-right" id="add_order_item">Add</button>
        </th>
      </tr>
      <tr>
        <th>
          Item
        </th>
        <th>
          Quantity
        </th>
        <th>
          Amount
        </th>
        
        <th>

        </th>
      </tr>
    </thead>
    <tbody>

    </tbody>
    <tfoot>
        <tr>
            <th colspan="3">
                Total
            </th>
            <th>
                <input type="number" class="form-control input_amount" name="price_total" value="<?php if($res1['cl_price_calculation'] == 'Automatic'){echo $total;}else{echo $res1['cl_price_total'];} ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                <div class="error_input"></div>
            </th>
        </tr>
        <tr>    
            <th colspan="3">
                PVN
            </th>
            <th>
                <input type="number" class="form-control input_amount" name="pvn" value="<?php if($res1['cl_price_calculation'] == 'Automatic'){echo $pvn;}else{echo $res1['cl_pvn'];} ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                <div class="error_input"></div>
            </th>
       
        </tr>
        <tr>
            <th colspan="3">
                Grand Total
            </th>
            <th>
                <input type="number" class="form-control input_amount" name="grand_total" value="<?php if($res1['cl_price_calculation'] == 'Automatic'){echo $grandtotal;}else{echo $res1['cl_grand_total'];} ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                <div class="error_input"></div>
            </th>
        
         </tr>
        <tr>
            <th colspan="3">
                Amount after Promocode
            </th>
            <th>
                <input type="number" class="form-control input_amount" name="priceAfterPromoCode" value="<?php echo $res1['cl_priceAfterPromoCode'] ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                <div class="error_input"></div>
            </th>
        </tr>
        <tr>
            <th colspan="3">
                VAT Percentage
            </th>
            <th>
                 <?php 

                 if($res1['cl_price_calculation'] == 'Automatic'){
                    $vatPercentage = $grandtotal * $taxPercentage/100;
                }
                else
                {
                    $vatPercentage = $res1['cl_vat_amount'];
                }

                     ?>
                
                <input type="number" class="form-control input_amount" name="vat_amount" value="<?php echo $vatPercentage ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                <div class="error_input"></div>
            </th>
        </tr>
        <tr>
            <th colspan="3">
                Final Total
            </th>
            <th>
                   <?php    
                   if($res1['cl_price_calculation'] == 'Automatic'){
                        $finalTotal = $grandtotal + $vatPercentage;
                    }
                    else{
                        $finalTotal = $res1['cl_total'];
                    } ?>
                <input type="number" class="form-control input_amount" name="total" value="<?php echo $finalTotal ?>" <?php if($res1['cl_price_calculation'] == 'Automatic'){echo 'disabled';} ?> />
                <div class="error_input"></div>
            </th>
        </tr>
    </tfoot>

  </table>
</div>

                                             <div class="btn-container col-xs-12 col-sm-12 pull-left" style="margin-top:15px">
                         
                                <?php
                                        if($res1['cl_invoice'] == 0)
                                        {
                                    ?>
                                        <button type="button" cluster-url="../ajax/convert_to_invoice_without_email?id=<?php echo $id;?>" class="btn btn-success pull-right btn-link-new" cluster-redirect="view?id=<?php echo $id;?>" cluster-message="Converting order to Invoice">Convert to Invoice (Without email)</button>
                                       <button type="button" cluster-url="../ajax/convert_to_invoice?id=<?php echo $id;?>" class="btn btn-primary pull-right btn-link-new" cluster-redirect="view?id=<?php echo $id;?>" cluster-message="Converting order to Invoice" style="margin-right:5px">Convert to Invoice (With Email)</button>
                                       <div class="error-area col-sm-12 pull-left"></div>
                                       <?php
                                        }
                                        else 
                                        {
                                       ?>
                                       <button class="btn btn-primary pull-right btn-link-new" cluster-url="../ajax/send_invoice_again?id=<?php echo $id;?>" cluster-message="Sending Email"> Sent Inoice again to customer</button>
                                        <button class="btn btn-success pull-right "  disabled="disabled" style="margin-right : 5px"><i class="fa fa-check"></i>  Conveted to Invoice</button>

                                        <div class="error-area col-sm-12 pull-left"></div>
                                         <?php
                                        }
                                        ?>
                                    </div>
                                        
                                        
                                        </div>
                                        
                                       
                                    </div>

</div>

<?php
}
?>

                        <script src="../jquery_file_upload/js/vendor/jquery.ui.widget.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="../jquery_file_upload/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="../jquery_file_upload/js/jquery.fileupload.js"></script>  
                    <script>
							$(document).ready(function(){
								$('.active').removeClass('active');
								$('#device-menu').addClass('active');

                                $('.input_amount').change(function(){
                                    var name = $(this).attr('name');
                                    var value = $(this).val();
                                    var parent = $(this).parents('tr').first();
                                    $(parent).find('.error_input').html('<div class="alert alert-warning">Changing Total</div>');
                                    $.post("../ajax/user_orders/update_total?id=<?php echo $id ?>", {name:name, value:value}, function(res){
                                        $(parent).find('.error_input').html('<div class="alert alert-success">' + res.message + '</div>');
                                    }, 'json').fail(function(xhr) {
                                        
                                          var html = '';
                                          var res = xhr.responseJSON;
                                          console.log(xhr);
                                          if (typeof res === 'undefined') {
                                            $(parent).find('.error_input').html('<div class="alert alert-danger">Something went wrong</div>').show();
                                          }
                                          if (typeof res.error_description === 'undefined') {
                                            if(typeof res.error_text === 'undefined')
                                            {
                                                $(parent).find('.error_input').html('<div class="alert alert-danger">Something went wrong</div>').show();
                                               
                                                return;
                                            }
                                            else
                                            {
                                                $(parent).find('.error_input').html('<div class="alert alert-danger">' + res.error_text + '</div>').show();
                                              
                                                return;
                                            }
                                          }
                                        
                                       
                                    });
                                });
							}); 

                            jQuery(document).on('change', '.item_field', function(){
                                 var name = $(this).attr('name');
                                  var value = $(this).val();
                                 var parent = $(this).parents('tr').first();
                                 var parentTD = $(this).parents('td').first();
                                    var id = $(parent).attr('cluster-id');
                                 $(parentTD).find('.error_input').html('<div class="alert alert-warning">Changing Total</div>');
                                    $.post("../ajax/user_orders/update_item_total?id=" + id, {name:name, value:value}, function(res){
                                        $(parentTD).find('.error_input').html('<div class="alert alert-success">' + res.message + '</div>');
                                    }, 'json').fail(function(xhr) {
                                        
                                          var html = '';
                                          var res = xhr.responseJSON;
                                          console.log(xhr);
                                          if (typeof res === 'undefined') {
                                            $(parentTD).find('.error_input').html('<div class="alert alert-danger">Something went wrong</div>').show();
                                          }
                                          if (typeof res.error_description === 'undefined') {
                                            if(typeof res.error_text === 'undefined')
                                            {
                                                $(parentTD).find('.error_input').html('<div class="alert alert-danger">Something went wrong</div>').show();
                                               
                                                return;
                                            }
                                            else
                                            {
                                                $(parentTD).find('.error_input').html('<div class="alert alert-danger">' + res.error_text + '</div>').show();
                                              
                                                return;
                                            }
                                          }
                                        
                                       
                                    });
                            });



                            jQuery(document).on('change', '.item_code', function(){
                                var code = jQuery(this).val();
                                 var parent = $(this).parents('tr').first();
                                 var parentTD = $(this).parents('td').first();
                                    var id = $(parent).attr('cluster-id');
                                     $(parentTD).find('.error_input').html('<div class="alert alert-warning">Updating Code</div>');
                                $.post("../ajax/user_orders/update_code?id=" + id, {code:code}, function(res){
                                        $(parentTD).find('.error_input').html('<div class="alert alert-success">' + res.message + '</div>');
                                    }, 'json').fail(function(xhr) {
                                        
                                          var html = '';
                                          var res = xhr.responseJSON;
                                          console.log(xhr);
                                          if (typeof res === 'undefined') {
                                            $(parentTD).find('.error_input').html('<div class="alert alert-danger">Something went wrong</div>').show();
                                          }
                                          if (typeof res.error_description === 'undefined') {
                                            if(typeof res.error_text === 'undefined')
                                            {
                                                $(parentTD).find('.error_input').html('<div class="alert alert-danger">Something went wrong</div>').show();
                                               
                                                return;
                                            }
                                            else
                                            {
                                                $(parentTD).find('.error_input').html('<div class="alert alert-danger">' + res.error_text + '</div>').show();
                                              
                                                return;
                                            }
                                          }
                                        
                                       
                                    });
                            });
						</script>      
                        <script>
                        $(function () {
                                'use strict';
   
                            var url = '../ajax/upload_invoice';
                            $('.fileupload').fileupload({
                                url: url,
                                dataType: 'json',
                                submit: function(e,data){
                                  var parent = $(this).parents('.input-container').first();
                                  $(parent).find('.files_area').html('');
                                  $(parent).find('.error_area').html('<div class="alert alert-warning">Upload in progress</div>');
                                  $(parent).find('.progress .progress-bar').removeAttr('style');


                                },
                                done: function (e, data) {
                                    /*$.each(data.result.files, function (index, file) {
                                        console.log(file);
                                    });*/
                                   
                                    var parent = $(this).parents('.input-container').first();
                                    $(parent).find('.files_area').html('<a target="_blank" class="" href="../uploads/invoice/' + data.result.file + '">Download</a>');
                                    $(parent).find('.file_name').text(data.result.actualName);
                                    $(parent).find('.error_area').html('');
                                    $(parent).find('.image').val(data.result.file);
                                    $(parent).find('.name').val(data.result.actualName);
                                },
                                fail: function (e, data) {
                                  var parent = $(this).parents('.input-container').first();
                                  $(parent).find('.error_area').html('<div class="alert alert-danger">' + data.jqXHR.responseJSON.error_text + '</div>');
                                  $(parent).find('.progress .progress-bar').css(
                                        'background-color',
                                        'salmon'
                                    );
                                },
                                progressall: function (e, data) {
                                  var parent = $(this).parents('.input-container').first();
                                    var progress = parseInt(data.loaded / data.total * 100, 10);
                                     $(parent).find('.progress .progress-bar').css(
                                        'width',
                                        progress + '%'
                                    );
                                }
                            }).prop('disabled', !$.support.fileInput)
                                .parent().addClass($.support.fileInput ? undefined : 'disabled');


                          
                            $('.fileuploadWarrantyCard').fileupload({
                                url: '../ajax/upload_warranty_card',
                                dataType: 'json',
                                submit: function(e,data){
                                  var parent = $(this).parents('.input-container').first();
                                  $(parent).find('.files_area').html('');
                                  $(parent).find('.error_area').html('<div class="alert alert-warning">Upload in progress</div>');
                                  $(parent).find('.progress .progress-bar').removeAttr('style');


                                },
                                done: function (e, data) {
                                    /*$.each(data.result.files, function (index, file) {
                                        console.log(file);
                                    });*/
                                   
                                    var parent = $(this).parents('.input-container').first();
                                    $(parent).find('.files_area').html('<a target="_blank" class="" href="../uploads/warranty_card/' + data.result.file + '">Download</a>');
                                    $(parent).find('.file_name').text(data.result.actualName);
                                    $(parent).find('.error_area').html('');
                                    $(parent).find('.image').val(data.result.file);
                                    $(parent).find('.name').val(data.result.actualName);
                                },
                                fail: function (e, data) {
                                  var parent = $(this).parents('.input-container').first();
                                  $(parent).find('.error_area').html('<div class="alert alert-danger">' + data.jqXHR.responseJSON.error_text + '</div>');
                                  $(parent).find('.progress .progress-bar').css(
                                        'background-color',
                                        'salmon'
                                    );
                                },
                                progressall: function (e, data) {
                                  var parent = $(this).parents('.input-container').first();
                                    var progress = parseInt(data.loaded / data.total * 100, 10);
                                     $(parent).find('.progress .progress-bar').css(
                                        'width',
                                        progress + '%'
                                    );
                                }
                            }).prop('disabled', !$.support.fileInput)
                                .parent().addClass($.support.fileInput ? undefined : 'disabled');
                        });


  $(document).on('click', '#add_order_item', function(){
    var html = '<tr><td><input type="text" class="form-control product_name" /><input type="hidden" class="form-control product_id" /></td> <td><input type="number" class="form-control quantity" /></td><td class="amount"></td><td><button type="button" class="btn btn-xs btn-primary btn-add"><i class="fa fa-plus"></i></button><button type="button" class="btn btn-xs btn-danger delete-client"><i class="fa fa-trash"></i></button></td></tr>';
    $('#new_order_items tbody').append(html);
  });




  var options = {source: function(request,response) {
        $.ajax ({
            url: "../ajax/products/get_products",
            data: {name: request.term},
            dataType: "json",
            type:'POST',
            success: function( data ) {
            response( $.map( data, function( item ) {
                return {
                    label: item.cl_name,
                    value: item.cl_name,
                    data:item
                }
            }));
        } 
        })
    },
    minLength: 1,
    select: function( event, ui ) {
        
        var parent = $(this).parents('tr').first();
        $(parent).find('.product_id').val(ui.item.data.cl_id);
        $(parent).find('.quantity').val(1);
        

        var supplierPrice = ui.item.data.cl_supplier_price;
         if(supplierPrice < 20)
        {
            profitPercentage = <?php echo $profitPercentage0_20 ?>;
        }
        else if(supplierPrice >= 20 && supplierPrice <= 50)
        {
            profitPercentage = <?php echo $profitPercentage20_50 ?>;
        }
        else if(supplierPrice >= 50 && supplierPrice <= 100)
        {
            profitPercentage = <?php echo $profitPercentage50_100 ?>;
        }
        else if(supplierPrice >= 100 && supplierPrice <= 200)
        {
            profitPercentage = <?php echo $profitPercentage100_200 ?>;
        }
        else if(supplierPrice >= 200 && supplierPrice <= 800)
        {
          profitPercentage = <?php echo $profitPercentage200_800 ?>;
        }
        else
        {
          profitPercentage = <?php echo $profitPercentageMoreThan800 ?>;
        }


        var amount = Number(supplierPrice) + Number(supplierPrice * profitPercentage / 100);
        $(parent).find('.amount').text(amount);
        $(parent).find('.quantity').attr('cluster-price', amount);

    }
  };


  $(document).on('keydown.autocomplete','.product_name',function(){
      $(this).autocomplete(options);
  });


  $(document).on('change', '.quantity', function(){
    var parent = $(this).parents('tr').first();
    if($.isNumeric($(this).val()))
    {
      var price = $(this).attr('cluster-price');
      var finalPrice = price * $(this).val();
      $(parent).find('.amount').text(finalPrice);
    }
    else
    {
      $(parent).find('.amount').text(0);
    }
  });


  $(document).on('click', '.delete-client', function(){
    var conf = confirm("Are you sure you want to delete this?");
    if(!conf)
    {
      return;
    }
    var parent = $(this).parents('tr').first();
    $(parent).remove();
  });

  $(document).on('click', '.btn-add', function(){
    var parent = $(this).parents('tr').first();
    $(parent).find('button').attr('disabled', 'disabled');
    var data = new Object();
     data['product_id'] = $(parent).find('.product_id').val();
     data['quantity'] = $(parent).find('.quantity').val();
    $.post('../ajax/user_orders/add_item?id=<?php echo $id ?>', {data:data}, function(){
        location.reload();
    },'json').fail(function(xhr) {
               $(parent).find('button').removeAttr('disabled');
            });
  });
      
                        </script>   


<script>
    jQuery(document).ready(function(){
        jQuery('#order_email_again').click(function(){
            jQuery('#order_email_again').attr('disabled', 'disabled');
            jQuery('.order_email_error').html('<div class="alert alert-warning">Sending Email</div>');
            jQuery.post('../ajax/user_orders/send_order_email?id=<?php echo $id ?>', function(){
                jQuery('#order_email_again').removeAttr('disabled');
                jQuery('.order_email_error').html('<div class="alert alert-success">Email Sent Successfully</div>');
            },'json')
            .fail(function(xhr) {
                jQuery('#order_email_again').removeAttr('disabled');
                jQuery('.order_email_error').html('<div class="alert alert-danger">Something Went Wrong</div>');
            });
        });

        jQuery('#invoice_create').click(function(){
            jQuery('#invoice_create').attr('disabled', 'disabled');
            jQuery('.order_email_error').html('<div class="alert alert-warning">Creating Invoice</div>');
            jQuery.post('../ajax/user_orders/send_order_email?id=<?php echo $id ?>&email=no', function(){
                jQuery('#invoice_create').removeAttr('disabled');
                jQuery('.order_email_error').html('<div class="alert alert-success">Invoice created Successfully</div>');
            },'json')
            .fail(function(xhr) {
                jQuery('#order_email_again').removeAttr('disabled');
                jQuery('.order_email_error').html('<div class="alert alert-danger">Something Went Wrong</div>');
            });
        });
    });


    jQuery(document).on('click', '.btn-delete-existing', function(){
        var parent = $(this).parents('tr').first();
        $(parent).find('button').attr('disabled', 'disabled');
        var id = $(this).attr('cluster-id');
        $.get('../ajax/user_orders/delete_item', {id:id}, function(){
            location.reload();
        },'json').fail(function(xhr) {
            $(parent).find('button').removeAttr('disabled');
            var res = xhr.responseJSON;
             if (typeof res === 'undefined') {
                $(parent).find('.delete_error').html('<div class="alert alert-danger">Something went wrong</div>').show();
              }
              if (typeof res.error_description === 'undefined') {
                if(typeof res.error_text === 'undefined')
                {
                    $(parent).find('.delete_error').html('<div class="alert alert-danger">Something went wrong</div>').show();
                    window.location.href = '#body_part';
                    return;
                }
                else
                {
                    $(parent).find('.delete_error').html('<div class="alert alert-danger">' + res.error_text + '</div>').show();
                    window.location.href = '#body_part';
                    return;
                }
              }
            
        });
    });

    jQuery(document).on('change', '#status', function(){
        if(jQuery(this).val() == 'Delivered')
        {
             var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];;
            var d = new Date();
            var dateValue = d.getDate() + ' ' + months[d.getMonth()] + ' ' + d.getFullYear();
            if(jQuery('#delivery_date').val() == '')
            {
                jQuery('#delivery_date').val(dateValue);
            }
        }
    });

    jQuery(document).ready(function(){
        jQuery('#label_create').click(function(){
            jQuery(this).attr('disabled', 'disabled');
            var current = jQuery(this);
            jQuery('.order_email_error').html('<div class="alert alert-warning">Creating Shipment.....</div>');
            $.get('../ajax/user_orders/create_shipment', {id:<?php echo $id ?>}, function(res){
                jQuery(current).removeAttr('disabled');
                 jQuery('.order_email_error').html('<div class="alert alert-success">' + res.message + '</div>');
                 jQuery('#tracking_number').val(res.tracking_number);
                location.reload();
            },'json').fail(function(xhr) {
                 jQuery(current).removeAttr('disabled');
                $(parent).find('button').removeAttr('disabled');
                var res = xhr.responseJSON;
                 if (typeof res === 'undefined') {
                    $('.order_email_error').html('<div class="alert alert-danger">Something went wrong</div>').show();
                  }
                  if (typeof res.error_description === 'undefined') {
                    if(typeof res.error_text === 'undefined')
                    {
                        $('.order_email_error').html('<div class="alert alert-danger">Something went wrong</div>').show();
                        window.location.href = '#body_part';
                        return;
                    }
                    else
                    {
                        $('.order_email_error').html('<div class="alert alert-danger">' + res.error_text + '</div>').show();
                        window.location.href = '#body_part';
                        return;
                    }
                  }
                
            });
        });
    });
</script>

  <?php
  include '../footer.php';
  ?>