HOME


Mini Shell 1.0
DIR: /home/islapiiu/sites/pramudi/class/
Upload File :
Current File : /home/islapiiu/sites/pramudi/class/Order.php
<?php

/**
 * Description of Order
 *
 * @author U s E r ยจ
 */
class Order
{
    public $id;
    public $orderedAt;
    public $member;
    public $address;
    public $city;
    public $contactNo1;
    public $contactNo2;
    public $district;
    public $amount;
    public $delivery_charges;
    public $orderNote;
    public $status;
    public $paymentStatusCode;
    public $statusCode;
    public $txnid;
    public $deliveryStatus;
    public $deliveredAt;
    public $completedAt;
    public $canceledAt;
    public function __construct($id)
    {
        if ($id) {
            $query = "SELECT *  FROM `orders` WHERE `id`='" . $id . "'";
            $db = new Database();
            $result = mysql_fetch_assoc($db->readQuery($query));

            $this->id = $result['id'];
            $this->orderedAt = $result['ordered_at'];
            $this->member = $result['member'];
            $this->address = $result['address'];
            $this->city = $result['city'];
            $this->contactNo1 = $result['contact_no_1'];
            $this->contactNo2 = $result['contact_no_2'];
            $this->district = $result['district'];
            $this->amount = $result['amount'];
            $this->delivery_charges = $result['delivery_charges'];
            $this->orderNote = $result['order_note'];
            $this->status = $result['status'];
            $this->paymentStatusCode = $result['payment_status_code'];
            $this->statusCode = $result['status_code'];
            $this->txnid = $result['txnid'];
            $this->deliveryStatus = $result['delivery_status'];
            $this->deliveredAt = $result['delivered_at'];
            $this->completedAt = $result['completed_at'];
            $this->canceledAt = $result['canceled_at'];
            return $result;
        }
    }
    public function create()
    {
        $db = new Database();
        $query = "INSERT INTO `orders` ("
            . "`ordered_at`,"
            . "`member`,"
            . "`address`,"
            . "`city`,"
            . "`contact_no_1`,"
            . "`contact_no_2`,"
            . "`district`,"
            . "`amount`,"
            . "`delivery_charges`,"
            . "`order_note`,"
            . "`status`,"
            . "`payment_status_code`,"
            . "`delivery_status`,"
            . "`delivered_at`,"
            . "`completed_at`,"
            . "`canceled_at`) VALUES  ("
            . "'" . $this->orderedAt . "', "
            . "'" . $this->member . "', "
            . "'" . mysql_real_escape_string($this->address) . "', "
            . "'" . $this->city . "', "
            . "'" . $this->contactNo1 . "', "
            . "'" . $this->contactNo2 . "', "
            . "'" . $this->district . "', "
            . "'" . $this->amount . "', "
            . "'" . $this->delivery_charges . "', "
            . "'" . mysql_real_escape_string($this->orderNote) . "', "
            . "'" . 0 . "', "
            . "'" . $this->paymentStatusCode . "', "
            . "'" . $this->deliveryStatus . "', "
            . "'" . $this->deliveredAt . "', "
            . "'" . $this->completedAt . "', "
            . "'" . $this->canceledAt . "')";
        // dd($query);
        $result = $db->readQuery($query);
        if ($result) {
            $last_id = mysql_insert_id();
            return $last_id;
        } else {
            return FALSE;
        }
    }
    public function all()
    {
        $query = "SELECT * FROM `orders` ORDER BY `id` DESC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getOrdersByDateRange($from, $to, $status)
    {
        $query = "SELECT * FROM `orders` WHERE `delivery_status`='" . $status . "' AND `status`='1' AND (`ordered_at` BETWEEN '" . $from . "' AND '" . $to . "' OR `ordered_at` LIKE '%" . $to . "%')";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getOrdersByCustomer($customer)
    {
        $query = "SELECT * FROM `orders` WHERE `member`='" . $customer . "' ORDER BY `id` DESC";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getUnpaidOrdersByDateRange($from, $to)
    {
        $query = "SELECT * FROM `orders` WHERE `status`='0' AND (`ordered_at` BETWEEN '" . $from . "' AND '" . $to . "' OR `ordered_at` LIKE '%" . $to . "%') ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getPaidOrders()
    {
        $query = "SELECT * FROM `orders` WHERE `status`='1' ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function updateResponse($id, $status)
    {
        $query = "UPDATE `orders` SET "
            . "`status` ='" . $status . "' "
            . " WHERE `id` = '" . $id . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    public function delete()
    {
        $this->deleteOrderProducts();
        $query = 'DELETE FROM `orders` WHERE id="' . $this->id . '"';
        $db = new Database();
        return $db->readQuery($query);
    }
    public function deleteOrderProducts()
    {
        $ORDER_PRODUCT = new OrderProduct(NULL);
        $allOrderProducts = $ORDER_PRODUCT->getOrdersById($this->id);
        foreach ($allOrderProducts as $order_products) {
            $ORDER_PRODUCT_OBJ = new OrderProduct($order_products["id"]);
            $ORDER_PRODUCT_OBJ->delete();
        }
    }
    public function getLastID()
    {
        $query = "SELECT `id` FROM `orders` ORDER BY `id` DESC LIMIT 1";
        $db = new Database();
        $result = mysql_fetch_assoc($db->readQuery($query));
        return $result['id'];
    }
    function updatePaymentStatusCodeAndStatus()
    {
        
        $query = "UPDATE  `orders` SET "
            . "`payment_status_code` ='" . $this->paymentStatusCode . "', "
            . "`status_code` ='" . $this->statusCode . "', "
            . "`txnid` ='" . $this->txnid . "' "
            // . "`status` ='" . $this->status . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function updatePaymentStatusCode()
    {
        $query = "UPDATE  `orders` SET "
            . "`payment_status_code` ='" . $this->paymentStatusCode . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function markAsDelivered()
    {
        date_default_timezone_set('Asia/Colombo');
        $deliveredAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`delivery_status` ='1', "
            . "`delivered_at` ='" . $deliveredAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function markAsCompleted()
    {
        date_default_timezone_set('Asia/Colombo');
        $completedAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`delivery_status` ='2', "
            . "`completed_at` ='" . $completedAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function confirmOrder()
    {
        date_default_timezone_set('Asia/Colombo');
        $confirmedAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`status` ='1', "
            . "`delivered_at` ='" . $confirmedAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function completeOrder()
    {
        date_default_timezone_set('Asia/Colombo');
        $completedAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`status` ='2', "
            . "`completed_at` ='" . $completedAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function cancelOrder()
    {
        date_default_timezone_set('Asia/Colombo');
        $canceledAt = date('Y-m-d H:i:s');
        $query = "UPDATE  `orders` SET "
            . "`status` ='3', "
            . "`canceled_at` ='" . $canceledAt . "' "
            . " WHERE `id` = '" . $this->id . "'  ";
        $db = new Database();
        $result = $db->readQuery($query);

        if ($result) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    public function deleteOrder()
    {
        $query = 'DELETE FROM `orders` WHERE id="' . $this->id . '"';
        $db = new Database();
        return $db->readQuery($query);
    }
    public function getPaymentStatusCode($order)
    {
        $query = "SELECT `payment_status_code` FROM `orders` WHERE `id` = $order";
        $db = new Database();
        $result = mysql_fetch_array($db->readQuery($query));
        return $result["payment_status_code"];
    }
    public function getOrdersByDeliveryStatusDescending($status)
    {
        $query = "SELECT * FROM `orders` WHERE `delivery_status`='" . $status . "' AND `payment_status_code` != 4 AND `status`='1' ORDER BY `id` DESC ";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getOrdersByDeliveryStatus($status)
    {
        $query = "SELECT * FROM `orders` WHERE `status`='" . $status . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getCanceledOrders()
    {
        $query = "SELECT * FROM `orders` WHERE `status`='3'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }
    public function getRefundOrders()
    {
        $query = "SELECT * FROM `orders` WHERE `payment_status_code`='4'";
        $db = new Database();
        $result = $db->readQuery($query);
        $array_res = array();
        while ($row = mysql_fetch_array($result)) {
            array_push($array_res, $row);
        }
        return $array_res;
    }

    function sendOrderMail()
    {
        $products = OrderProduct::getProductsByOrder($this->id);

        $CUSTOMER = new Customer($this->member);
        $DISTRICT = new District($this->district);

        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "http://" . $_SERVER['HTTP_HOST'];

        //----------------------- DISPLAY STRINGS ---------------------
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $customer_msg = 'Hello, and thank you for your interest in ' . $comany_name . '. We have received your enquiry, and we will get back to you as soon as possible.';


        $visitor_name = $CUSTOMER->name;
        $visitor_email = $CUSTOMER->email;
        //    $visitor_phone = $CUSTOMER->phone_number;
        //    $message = $_POST['message'];


        //------------------------ MAIL ESSENTIALS --------------------------------

        $webmail = "[email protected]";
        $visitorSubject = "Order Enquiry - #" . $this->id;
        $companySubject = "Order Enquiry - #" . $this->id;

        $delivery_charge = $this->delivery_charges;

        $tr = '';
        $tot = 0;
        $id = 0;
        foreach ($products as $key => $product) {

            $PRODUCT = new Product($product['product']);

            // if ($PRODUCT->parent  != 0) {
            //     $PARANT = new Product($PRODUCT->parent);
            //     $name = $PARANT->name . ' - ' . $product["product_name"];
            // } else {
            $name =  $PRODUCT->name;
            // }

            $tot += $product['amount'];
            $id++;
            $tr .= '<tr>';
            $tr .= '<td>' . $id . '</td>';
            $tr .= '<td>' . $name . '</td>';
            $tr .= '<td>' . $product['qty'] . '</td>';
            $tr .= '<td style="text-align: right;">' . number_format($product['amount'], 2) . ' LKR</td>';
            $tr .= '</tr>';
        }

        $grand_total = $tot + $delivery_charge;
        if ($this->paymentStatusCode == 2 && $this->statusCode == 'Completed') {
            $paymentstatus = "Success";
        } elseif ($this->paymentStatusCode == 2 && $this->statusCode == 'Pending') {
            $paymentstatus = "Pending";
        } else {
            $paymentstatus = "Failed";
        }
        if ($this->status == 0) {
            $status = "Pending";
        } elseif ($this->status == 1) {
            $status = "Confirmed";
        }
        if (empty($this->contactNo2)) {
            $conNo2 = '-';
        } else {
            $conNo2 = $this->contactNo2;
        }

        $visitor_message = '<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>Synotec Email</title>
        </head>
        <body>
            <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                <tbody>
                    <tr> 
                        <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                            <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                <tbody>
                                    <tr> 
                                        <td bgcolor=""> 
                                            <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                                <tbody> 
                                                    <tr> 
                                                        <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                                <tbody>
                                                                    <tr><td>
                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                <tbody>
                                                                                    <tr>
                                                                                        <td width="100%">
                                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                                <tbody>
                                                                                                    <tr>
                                                                                                        <td valign="middle" height="46" align="right">
                                                                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                                <tbody>
                                                                                                                    <tr>
                                                                                                                        <td width="100%" align="center">
                                                                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                                <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.gallecabsandtours.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                    <h4>' . $website_name . '</h4>
                                                                                                                                </a>
                                                                                                                            </font>
                                                                                                                        </td>
                                                                                                                    </tr>
                                                                                                                </tbody>
                                                                                                            </table>
                                                                                                        </td>
                                                                                                    </tr>
                                                                                                </tbody>
                                                                                            </table>
                                                                                        </td>
                                                                                    </tr>
                                                                                </tbody>
                                                                            </table>
                                                                        </td>
                                                                    </tr>
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $this->full_name . ' </td> 
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                            <p>Thank you for purchasing with us and find the attached details of the purchase below. Do not be hesitate to contact us via hotline for any enquiries.</p></td> 
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                        </td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                    </tr> 
                                                    <tr> 
                                                        <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                            <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <ul>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                    Full Name : ' . $visitor_name . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                    Email : ' . $visitor_email . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                    Contact No : ' . $this->contactNo1 . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                   Additional Contact No : ' . $conNo2 . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Address : ' . $this->address . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    District : ' . $DISTRICT->name . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Ordered At : ' . $this->orderedAt . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Order Status : ' . $status . '
                                                                                </font>
                                                                            </li>
                                                                            <li>
                                                                                <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                    Payment Status : ' . $paymentstatus . '
                                                                                </font>
                                                                            </li>
                                                                                
                                                                                <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                    <thead>
                                                                                        <tr>
                                                                                            <th>ID</th>
                                                                                            <th>Product</th>
                                                                                            <th>Qty</th>
                                                                                            <th>Amount</th>
                                                                                        </tr>
    
                                                                                    </thead>
                                                                                    <tbody>
                                                                                        ' . $tr . '
                                                                                    </tbody>
                                                                                    <tfoot>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($tot, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($delivery_charge, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($grand_total, 2) . ' </th>
                                                                                        </tr>
                                                                                    </tfoot>
                                                                                </table>
                                                                        </ul>
                                                                    </tr> 
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:10px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px 10px" align="left"> <p> Cheers, </p>
                                                                            <p> ' . $comOwner . ' </p>
                                                                        </td> 
                                                                    </tr>
                                                                    <tr> 
                                                                        <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                            <p>* Special Note - Do not delete this e-mail, instead keep it as the invoice to submit the delivery person.</p></td> 
                                                                    </tr> 
                                                                        
                                                                </tbody> 
                                                            </table> 
                                                            <table style="background-color:#fff" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff"> 
                                                                
                                                                <tbody>
                                                                    <tr> 
                                                                        <td style="padding:10px 20px 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0"> 
                                                                            </p><p style="line-height:24px;margin:0;padding:0">' . $comany_name . '</p>
                                                                            <p style="line-height:24px;margin:0;padding:0">Email : ' . $comEmail . ' </p> 
                                                                            <p style="line-height:24px;margin:0;padding:0">Tel: ' . $comConNumber . '</p> </td> 
                                                                    </tr> 
                                                                </tbody>
                                                            </table> 
                                                        </td> 
                                                    </tr> 
                                                </tbody> 
                                            </table>
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td id="m_-1040695829873221998footer_content"> 
                                            <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                                <tbody>
                                                    <tr> 
                                                        <td> 
                                                            <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                                <tbody> 
                                                                    <tr> 
                                                                        <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                    </tr> 
                                                                    <tr></tr> 
                                                                </tbody> 
                                                            </table>
                                                        </td> 
                                                    </tr> 
                                                </tbody>
                                            </table> 
                                        </td> 
                                    </tr> 
                                </tbody>
                            </table>
                        </td> 
                    </tr> 
                </tbody>
            </table>
        </body>
    </html>';

        $company_message = '<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Synotec Email</title>
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
            <tbody>
                <tr> 
                    <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                        <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                            <tbody>
                                <tr> 
                                    <td bgcolor=""> 
                                        <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                            <tbody> 
                                                <tr> 
                                                    <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody>
                                                                <tr><td>
                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td width="100%">
                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                            <tbody>
                                                                                                <tr>
                                                                                                    <td valign="middle" height="46" align="right">
                                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                            <tbody>
                                                                                                                <tr>
                                                                                                                    <td width="100%" align="center">
                                                                                                                        <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                            <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.gallecabsandtours.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                <h4>' . $website_name . '</h4>
                                                                                                                            </a>
                                                                                                                        </font>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </tbody>
                                                                                                        </table>
                                                                                                    </td>
                                                                                                </tr>
                                                                                            </tbody>
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </tbody>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $comany_name . ' </td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p> You have a new order enquiry from your website on ' . $todayis . ' as follows. Please pay your attention as soon as possible.</p></td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <ul>
                                                                    <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                        Full Name : ' . $visitor_name . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                        Email : ' . $visitor_email . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                        Contact No : ' . $this->contactNo1 . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                       Additional Contact No : ' . $conNo2 . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Address : ' . $this->address . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        District : ' . $DISTRICT->name . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Ordered At : ' . $this->orderedAt . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Order Status : ' . $status . '
                                                                    </font>
                                                                </li>
                                                                <li>
                                                                    <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                        Payment Status : ' . $paymentstatus . '
                                                                    </font>
                                                                </li>
                                                                        <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                <thead>
                                                                                    <tr>
                                                                                        <th>ID</th>
                                                                                        <th>Product</th>
                                                                                        <th>Qty</th>
                                                                                        <th>Amount</th>
                                                                                    </tr>

                                                                                </thead>
                                                                                <tbody>
                                                                                    ' . $tr . '
                                                                                </tbody>
                                                                                <tfoot>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($tot, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($delivery_charge, 2) . ' </th>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                            <th style="text-align: right;">US $ ' . number_format($grand_total, 2) . ' </th>
                                                                                        </tr>
                                                                                    </tfoot>
                                                                            </table>
                                                                    </ul>
                                                                </tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody> 
                                        </table>
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td id="m_-1040695829873221998footer_content"> 
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                            <tbody>
                                                <tr> 
                                                    <td> 
                                                        <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                </tr> 
                                                                <tr></tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody>
                                        </table> 
                                    </td> 
                                </tr> 
                            </tbody>
                        </table>
                    </td> 
                </tr> 
            </tbody>
        </table>
    </body>
</html>';

        $HELPER = new Helper();
        $visitorMail = $HELPER->PHPMailer($webmail, $comany_name, $comEmail, $comany_name, $visitor_email, $visitor_name, $visitorSubject, $visitor_message);
        $companyMail = $HELPER->PHPMailer($webmail, $visitor_name, $visitor_email, $visitor_name, $comEmail, $comany_name, $companySubject, $company_message);

        if ($visitorMail && $companyMail) {
            $arr['status'] = "Your message has been sent successfully";
        } else {
            $arr['status'] = "Could not be sent your message";
        }

        return $arr;
    }


    function sendOrderMail1($products)
    {
        $CUSTOMER = new Customer($this->member);
        $DISTRICT = new District($this->district);
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "https://" . $_SERVER['HTTP_HOST'];
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $visitor_email = $CUSTOMER->email;
        $visitor_name = $CUSTOMER->name;
        $webmail = "[email protected]";
        $visitorSubject = "Order Enquiry - #" . $this->id;
        $tr = '';
        $tot = 0;
        $id = 0;
        foreach ($products as $key => $product) {
            $PRODUCT = new Product($product['product']);
            $tot += $product['amount'];
            $id++;
            $tr .= '<tr>';
            $tr .= '<td>' . $id . '</td>';
            $tr .= '<td>' . $PRODUCT->name . '</td>';
            $tr .= '<td>' . $product['qty'] . ' ' . $PRODUCT->unit . '</td>';
            $tr .= '<td style="text-align: right;">US $' . number_format($product['amount'], 2) . '</td>';
            $tr .= '</tr>';
        }
        // $processing_fee = ($tot + 150) * 3 / 100;
        $grand_total = $tot + 0;
        $html = '<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Synotec Email</title>
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
            <tbody>
                <tr> 
                    <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                        <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                            <tbody>
                                <tr> 
                                    <td bgcolor=""> 
                                        <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                            <tbody> 
                                                <tr> 
                                                    <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody>
                                                                <tr><td>
                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td width="100%">
                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                            <tbody>
                                                                                                <tr>
                                                                                                    <td valign="middle" height="46" align="right">
                                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                            <tbody>
                                                                                                                <tr>
                                                                                                                    <td width="100%" align="center">
                                                                                                                        <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                            <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.pramudigems.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                <h4>' . $website_name . '</h4>
                                                                                                                            </a>
                                                                                                                        </font>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </tbody>
                                                                                                        </table>
                                                                                                    </td>
                                                                                                </tr>
                                                                                            </tbody>
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </tbody>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $CUSTOMER->name . ' </td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p>Thank you for purchasing with us and find the attached details of the purchase below. Do not be hesitate to contact us via hotline for any enquiries.</p></td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <ul>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Full Name : ' . $CUSTOMER->name . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Email : ' . $CUSTOMER->email . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Contact No : ' . $this->contactNo1 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                               Additional Contact No : ' . $this->contactNo2 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Address : ' . $this->address . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                State : ' . $DISTRICT->name . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Ordered At : ' . $this->orderedAt . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Status : Pending
                                                                            </font>
                                                                        </li>
                                                                            
                                                                            <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                <thead>
                                                                                    <tr>
                                                                                        <th>ID</th>
                                                                                        <th>Product</th>
                                                                                        <th>Qty</th>
                                                                                        <th>Amount</th>
                                                                                    </tr>
                                                                                </thead>
                                                                                <tbody>
                                                                                    ' . $tr . '
                                                                                </tbody>
                                                                                <tfoot>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($tot, 2) . '</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                        <th style="text-align: right;">US $0.00</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($grand_total, 2) . '</th>
                                                                                    </tr>
                                                                                </tfoot>
                                                                            </table>
                                                                    </ul>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:10px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px 10px" align="left"> <p> Cheers, </p>
                                                                        <p> ' . $comOwner . ' </p>
                                                                    </td> 
                                                                </tr>
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p>* Special Note - Do not delete this e-mail, instead keep it as the invoice to submit the delivery person.</p></td> 
                                                                </tr> 
                                                                    
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#fff" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#fff"> 
                                                            
                                                            <tbody>
                                                                <tr> 
                                                                    <td style="padding:10px 20px 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0"> 
                                                                        </p><p style="line-height:24px;margin:0;padding:0">' . $comany_name . '</p>
                                                                        <p style="line-height:24px;margin:0;padding:0">Email : ' . $comEmail . ' </p> 
                                                                        <p style="line-height:24px;margin:0;padding:0">Tel: ' . $comConNumber . '</p> </td> 
                                                                </tr> 
                                                            </tbody>
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                            </tbody> 
                                        </table>
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td id="m_-1040695829873221998footer_content"> 
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                            <tbody>
                                                <tr> 
                                                    <td> 
                                                        <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                </tr> 
                                                                <tr></tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody>
                                        </table> 
                                    </td> 
                                </tr> 
                            </tbody>
                        </table>
                    </td> 
                </tr> 
            </tbody>
        </table>
    </body>
</html>';
        $HELPER = new Helper();
        $visitorMail = $HELPER->PHPMailer($webmail, $comany_name, $comEmail, $reply_email_name, $visitor_email, $visitor_name, $visitorSubject, $html);
        if ($visitorMail) {
            $arr['status'] = "Your message has been sent successfully";
        } else {
            $arr['status'] = "Could not be sent your message";
        }
        return $arr;
    }
    function sendOrderMailToAdmin($products)
    {
        $CUSTOMER = new Customer($this->member);
        $DISTRICT = new District($this->district);
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "https://" . $_SERVER['HTTP_HOST'];
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $visitor_email = $CUSTOMER->email;
        $visitor_name = $CUSTOMER->name;
        $webmail = "[email protected]";
        $visitorSubject = "Order Enquiry - #" . $this->id;
        $tr = '';
        $tot = 0;
        $id = 0;
        foreach ($products as $key => $product) {
            $PRODUCT = new Product($product['product']);
            $tot += $product['amount'];
            $id++;
            $tr .= '<tr>';
            $tr .= '<td>' . $id . '</td>';
            $tr .= '<td>' . $PRODUCT->name . '</td>';
            $tr .= '<td>' . $product['qty'] . ' ' . $PRODUCT->unit . '</td>';
            $tr .= '<td style="text-align: right;">US $' . number_format($product['amount'], 2) . '</td>';
            $tr .= '</tr>';
        }
        // $processing_fee = ($tot + 150) * 3 / 100;
        $grand_total = $tot + 0;
        $status = "Pending";
        $html = '<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Synotec Email</title>
    </head>
    <body>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
            <tbody>
                <tr> 
                    <td style="padding-top:10px;padding-bottom:30px;padding-left:16px;padding-right:16px" align="center"> 
                        <table style="width:602px" width="602" cellspacing="0" cellpadding="0" border="0" align="center"> 
                            <tbody>
                                <tr> 
                                    <td bgcolor=""> 
                                        <table width="642" cellspacing="0" cellpadding="0" border="0"> 
                                            <tbody> 
                                                <tr> 
                                                    <td style="border:1px solid #dcdee3;padding:20px;background-color:#fff;width:600px" width="600px" bgcolor="#ffffff" align="center"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody>
                                                                <tr><td>
                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td width="100%">
                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="margin-bottom: 25px;">
                                                                                            <tbody>
                                                                                                <tr>
                                                                                                    <td valign="middle" height="46" align="right">
                                                                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0">
                                                                                                            <tbody>
                                                                                                                <tr>
                                                                                                                    <td width="100%" align="center">
                                                                                                                        <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:18px">
                                                                                                                            <a href="' . $site_link . '" style="color:#68696a;text-decoration:none;" target="_blank" data-saferedirecturl="https://www.google.com/url?q=http://www.pramudigems.com&amp;source=gmail&amp;ust=1574393192616000&amp;usg=AFQjCNGNM8_Z7ZMe7ndwFlJuHEP29nDd3Q">
                                                                                                                                <h4>' . $website_name . '</h4>
                                                                                                                            </a>
                                                                                                                        </font>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </tbody>
                                                                                                        </table>
                                                                                                    </td>
                                                                                                </tr>
                                                                                            </tbody>
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </tbody>
                                                                        </table>
                                                                    </td>
                                                                </tr>
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:15px 20px 10px;font-weight: 600;" align="left"> Hi , ' . $comany_name . ' </td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table style="background-color:#f5f7fa" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#F5F7FA"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="word-wrap:break-word;font-size:14px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:10px 20px" align="left"> 
                                                                        <p> You have a new order enquiry from your website on ' . $todayis . ' as follows. Please pay your attention as soon as possible.</p></td> 
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:4px 20px;width:600px;line-height:12px">&nbsp;</td> 
                                                </tr> 
                                                <tr> 
                                                    <td style="padding:20px;border:1px solid #dcdee3;width:600px;background-color:#fff"> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="font-size:15px;color:#333;line-height:18px;font-family:Arial,Helvetica,sans-serif;padding:0 0 8px;font-weight: 700;" align="left"> The Details :</td>
                                                                </tr> 
                                                            </tbody> 
                                                        </table> 
                                                        <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <ul>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Full Name : ' . $CUSTOMER->name . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Email : ' . $CUSTOMER->email . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                                Contact No : ' . $this->contactNo1 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family:Verdana,Geneva,sans-serif;color:#68696a;font-size:14px">
                                                                               Additional Contact No : ' . $this->contactNo2 . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Address : ' . $this->address . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                State : ' . $DISTRICT->name . '
                                                                            </font>
                                                                        </li>
                                                                            
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Ordered At : ' . $this->orderedAt . '
                                                                            </font>
                                                                        </li>
                                                                        <li>
                                                                            <font style="font-family: Verdana, Geneva, sans-serif; color:#68696a; font-size:14px; " >
                                                                                Status : ' . $status . '
                                                                            </font>
                                                                        </li>
                                                                        <table width="100%" border="1" style="margin-top: 10px" cellspacing="0" cellpadding="0">
                                                                                <thead>
                                                                                    <tr>
                                                                                        <th>ID</th>
                                                                                        <th>Product</th>
                                                                                        <th>Qty</th>
                                                                                        <th>Amount</th>
                                                                                    </tr>
                                                                                </thead>
                                                                                <tbody>
                                                                                    ' . $tr . '
                                                                                </tbody>
                                                                                <tfoot style="border: 1px solid #000">
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($tot, 2) . '</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Delivery Charges</th>
                                                                                        <th style="text-align: right;">US $0.00</th>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <th colspan="3" style="text-align: left;">Grand Total</th>
                                                                                        <th style="text-align: right;">US $' . number_format($grand_total, 2) . '</th>
                                                                                    </tr>
                                                                                </tfoot>
                                                                            </table>
                                                                    </ul>
                                                                </tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody> 
                                        </table>
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td id="m_-1040695829873221998footer_content"> 
                                        <table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f6f8fb"> 
                                            <tbody>
                                                <tr> 
                                                    <td> 
                                                        <table style="padding:0" width="100%" cellspacing="0" cellpadding="0" border="0" align="center"> 
                                                            <tbody> 
                                                                <tr> 
                                                                    <td style="padding:0px 0 7px;color:#9a9a9a;text-align:left;font-family:Arial,Helvetica,sans-serif;font-size:12px" align="left"> <p style="line-height:18px;margin:0;padding:0">Website By : <a href="https://synotec.lk/">Synotec Holdings</a></p> </td> 
                                                                </tr> 
                                                                <tr></tr> 
                                                            </tbody> 
                                                        </table>
                                                    </td> 
                                                </tr> 
                                            </tbody>
                                        </table> 
                                    </td> 
                                </tr> 
                            </tbody>
                        </table>
                    </td> 
                </tr> 
            </tbody>
        </table>
    </body>
</html>';
        $HELPER = new Helper();
        $companyMail = $HELPER->PHPMailer($webmail, $visitor_name, $visitor_email, $visitor_name, $comEmail, $comany_name, $visitorSubject, $html);
        if ($companyMail) {
            $arr['status'] = "Your message has been sent successfully";
        } else {
            $arr['status'] = "Could not be sent your message";
        }
        return $arr;
    }
    public function sendOrderConfirmedEmail()
    {
        date_default_timezone_set('Asia/Colombo');
        $todayis = date("l, F j, Y, g:i a");
        $site_link = "https://" . $_SERVER['HTTP_HOST'];
        $comany_name = "Pramudi Gem & Jewelry";
        $website_name = "www.pramudigems.com";
        $comConNumber = "(+94) 71 635 1651";
        $comEmail = "[email protected]";
        $comOwner = "Team Pramudi Gem & Jewelry";
        $reply_email_name = "PRAMUDI GEMS & JEWELRY";
        $CUSTOMER = new Customer($this->member);
        $visitor_email = $CUSTOMER->email;
        $visitor_name = $CUSTOMER->name;
        $webmail = "[email protected]";
        $visitorSubject = "Order Confirmation - (#" . $this->id . ")";
        // Compose a simple HTML email message
        $message = '<html>';
        $message .= '<body>';
        $message .= '<div  style="padding: 10px; max-width: 650px; background-color: #f2f1ff; border: 1px solid #d4d4d4;">';
        $message .= '<h4>Order Confirmation - (#' . $this->id . ')</h4>';
        $message .= '<p>Dear sir/madam, <br/>Your order (#' . $this->id . ') has been confiremd successfully.</p>';
        $message .= '<hr/>';
        $message .= '<p>Please click <a href="' . $site_link . '/member/view-order.php?id=' . $this->id . '" target="_blank">here</a> to check your order details.</p>';
        $message .= '<hr/>';
        $message .= '<p>Thanks & Best Regards!.. <br/> ' . $website_name . '<p/>';
        $message .= '<small>*Please do not reply to this email. This is an automated email & you will not receive a response.</small><br/>';
        $message .= '<span>Hotline: ' . $comConNumber . ' </span><br/>';
        $message .= '<span>' . $comEmail . '</span>';
        $message .= '</div>';
        $message .= '</body>';
        $message .= '</html>';
        $HELPER = new Helper();
        $visitorMail = $HELPER->PHPMailer($webmail, $comany_name, $comEmail, $reply_email_name, $visitor_email, $visitor_name, $visitorSubject, $message);
        if ($visitorMail) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
    function checkTxnid($txnid)
    {

        $query = "SELECT * FROM `orders` WHERE `txnid` = '" . mysql_real_escape_string($txnid) . "'";
        $db = new Database();
        $result = $db->readQuery($query);
        if ($result) {
            return FALSE;
        } else {
            return TRUE;
        }
    }
}