Esempio n. 1
0
    public function approvedAction()
    {
        $producturrency = new Admin_Model_DbTable_Countries();
        $modelAuthor = new Publisher_Model_DbTable_Publishers();
        $tempObj = new Model_DbTable_Checkout();
        $creditHistoryObj = new User_Model_DbTable_Chistory();
        $transactionHistoryObj = new User_Model_DbTable_Transactionhistory();
        $this->modelBooks = new Publisher_Model_DbTable_Books();
        $modelImage = new Publisher_Model_DbTable_BookImages();
        $modelStore = new Admin_Model_DbTable_Countries();
        $productPrice = new Publisher_Model_DbTable_BookPrices();
        $productPrice = new Publisher_Model_DbTable_BookPrices();
        $groupSubsObj = new Company_Model_DbTable_GroupSubscriptions();
        $response = $_POST['xmlmsg'];
        $xml_string = $_POST['xmlmsg'];
        $parsedxml = simplexml_load_string(stripslashes($response));
        //echo "<pre>";
        //print_r($parsedxml);
        $formDataTransApproved = array();
        foreach ($parsedxml as $RESPONSENODE) {
            //echo $RESPONSENODE."<br/>";
            if ($RESPONSENODE->getName() == 'OrderID') {
                $orderId = $RESPONSENODE;
                $orderIdForPurchase = $RESPONSENODE;
                $orderIdss = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'TransactionType') {
                $transactionType = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'PAN') {
                $pan = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'PurchaseAmountScr') {
                $purchaseAmount = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'TranDateTime') {
                $tranDateTime = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ResponseCode') {
                $responseCode = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ResponseDescription') {
                $responseDescription = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'OrderStatusScr') {
                $orderStatus = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ApprovalCode') {
                $approvalCode = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'MerchantTranID') {
                $merchantTranId = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'OrderDescription') {
                $orderDescription = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ApprovalCodeScr') {
                $approvalCodeScr = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'CurrencyScr') {
                $currency = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ThreeDSVerificaion') {
                $threeDsVerification = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'Brand') {
                $brandname = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'Name') {
                $card_holder_name = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ThreeDSStatus') {
                $ThreeDSStatus = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'MerchantTranID') {
                $MerchantTranID = $RESPONSENODE;
            }
        }
        $formDataTransApproved = array("orderId" => $orderId, "transactionType" => $transactionType, "pan" => $pan, "purchaseAmount" => $purchaseAmount, "tranDateTime" => $tranDateTime, "responseCode" => $responseCode, "responseDescription" => $responseDescription, "orderStatus" => $orderStatus, "approvalCode" => $approvalCode, "approvalCode" => $approvalCode, "merchantTranId" => $merchantTranId, "orderDescription" => $orderDescription, "approvalCodeScr" => $approvalCodeScr, "currency" => $currency, "brand" => $brandname, "card_holder_name" => $card_holder_name, "ThreeDSStatus" => $ThreeDSStatus, "threeDsVerification" => $threeDsVerification, "transaction_xml" => $xml_string);
        $inserted_id = $transactionHistoryObj->insert($formDataTransApproved);
        ##############  update table ###########################
        if ($orderStatus == 'APPROVED') {
            $orderSt = 1;
        } else {
            $orderSt = 0;
        }
        $tempTransactionUpdate = array("payment_status" => $orderSt, "transaction_id" => $inserted_id);
        //$tempObj->update($tempTransactionUpdate,'user_id="'.$user_id.'"');
        $creditHistoryObj->update($tempTransactionUpdate, "order_id='" . $orderId . "'");
        ##########################################################
        $total_price = '';
        $tempData = $tempObj->fetchAll("order_id='" . $orderId . "' and is_purchase!='1'");
        //$tempData = $tempObj->fetchAll("order_id='38115' and is_purchase!='1'");
        $order_details = "<table cellpadding='1'><tr><td colspan='3'>Your reference Id</td></tr><tr><td colspan='3'>Order ID:" . $orderId . "</td></tr><tr><td colspan='3'>Transaction ID:" . $inserted_id . "</td></tr><tr><td>Item</td><td>Price</td><td>Subscription Details</td><td>Number of Issues</td><td>Start Date</td><td>End Date</td><td>Quantity</td></tr>";
        $array_new = array();
        $new_product_array = array();
        foreach ($tempData as $dataDet) {
            $publication_det = $this->modelBooks->fetchRow("id='" . $dataDet['product_id'] . "'");
            if (@in_array($publication_det['publisher_id'], $array_new)) {
                $new_product_array[$publication_det['publisher_id']][] = array("id" => $dataDet['id'], "product_id" => $dataDet['product_id'], "user_id" => $dataDet['user_id'], "user_type" => $dataDet['user_type'], "store_id" => $dataDet['store_id'], "quntity" => $dataDet['quntity'], "group_id" => $dataDet['group_id'], "order_id" => $dataDet['group_id']);
            } else {
                array_push($array_new, $publication_det['publisher_id']);
                $new_product_array[$publication_det['publisher_id']][] = array("id" => $dataDet['id'], "product_id" => $dataDet['product_id'], "user_id" => $dataDet['user_id'], "user_type" => $dataDet['user_type'], "store_id" => $dataDet['store_id'], "quntity" => $dataDet['quntity'], "group_id" => $dataDet['group_id'], "order_id" => $dataDet['group_id']);
            }
        }
        $modelSubscription = new Publisher_Model_DbTable_Subscriptions();
        foreach ($tempData as $dataDet) {
            $order_idsids = $dataDet['order_id'];
            $productPriceInfo = $productPrice->getPriceByStoreId($dataDet['product_id'], $dataDet['store_id']);
            $subscription_data = $modelSubscription->fetchAll('id="' . $dataDet['subscription_type'] . '"');
            if ($dataDet['group_id'] != '' && $dataDet['group_id'] != 0) {
                $arrayDataGroup = '';
                $dateTime = date('Y-m-d H:i:s');
                $price = $productPriceInfo['group_price'];
                $arrayDataGroup = array("publication_id" => $dataDet['product_id'], "group_id" => $dataDet['group_id'], "company_id" => $dataDet['user_id'], "assigned_date" => $dateTime);
                $groupSubsObj->insert($arrayDataGroup);
            } else {
                $price = $productPriceInfo['price'];
            }
            $product_details = $this->modelBooks->fetchRow("id='" . $dataDet['product_id'] . "'");
            $getBrandInfo = $this->modelBooks->getBrandInfo($product_details['title']);
            if (!empty($getBrandInfo) && is_numeric($this->{$product_details}['title'])) {
                $titleBrand = $getBrandInfo['brand'];
            } else {
                $titleBrand = $product_details['title'];
            }
            if (!empty($product_details['parent_brand_id']) && $product_details['cat_id'] != '3') {
                $productInfo = $this->modelBooks->fetchRow('id="' . $product_details['parent_brand_id'] . '"');
                $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title);
                $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['publisher_id']);
                if (!empty($getParentBrandInfo)) {
                    //$titleBrand=$titleBrand.' ('.$getParentBrandInfo['brand'].')';
                    $titleBrand = $getParentBrandInfo['brand'] . " - " . $titleBrand . "<br/>" . $authorInfo['publisher'];
                }
            }
            $getCurrencyName = $producturrency->getCurrencyCode($dataDet['store_id']);
            $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['author_id']);
            $imageInfo = $modelImage->getImageInfoByProductId($product_details['id']);
            $sql1 = "update pclive_products set best_seller=best_seller+1 where id='" . $dataDet['product_id'] . "'";
            $result1 = $this->modelBooks->getAdapter()->query($sql1);
            $todaysdate = date('Y-m-d H:i:s');
            if ($dataDet['subscription_name'] == 'Weekly') {
                $date = new DateTime($todaysdate);
                $date->modify("+7 day");
                $end_date = $date->format("Y-m-d H:i:s");
            } else {
                if ($dataDet['subscription_name'] == 'Monthly') {
                    $date = new DateTime($todaysdate);
                    $date->modify("+30 day");
                    $end_date = $date->format("Y-m-d H:i:s");
                } else {
                    if ($dataDet['subscription_name'] == 'Quarterly') {
                        $date = new DateTime($todaysdate);
                        $date->modify("+90 day");
                        $end_date = $date->format("Y-m-d H:i:s");
                    } else {
                        if ($dataDet['subscription_name'] == 'Half Yearly') {
                            $date = new DateTime($todaysdate);
                            $date->modify("+182 day");
                            $end_date = $date->format("Y-m-d H:i:s");
                        } else {
                            if ($dataDet['subscription_name'] == 'Yearly') {
                                $date = new DateTime($todaysdate);
                                $date->modify("+365 day");
                                $end_date = $date->format("Y-m-d H:i:s");
                            }
                        }
                    }
                }
            }
            if (count($subscription_data) > 0) {
                $price_to_show = $dataDet['subscription_price'];
                $subtype = $dataDet['subscription_name'];
                $subscription_issues = $dataDet['subscription_issues'];
                $todaysdate = $todaysdate;
                $end_date = $end_date;
            } else {
                $price_to_show = $price;
                $subtype = "N/A";
                $subscription_issues = "N/A";
                $todaysdate = "N/A";
                $end_date = "N/A";
            }
            if ($dataDet['user_type'] == "1") {
                $finalsubprice = $price_to_show * $dataDet['quntity'];
            } else {
                $finalsubprice = $price_to_show;
            }
            $quntity_price = $finalsubprice;
            $price_quan = $producturrency->currencyconverter($getCurrencyName, "NGN", $quntity_price);
            $price_in = $producturrency->currencyconverter($getCurrencyName, "NGN", $price_to_show);
            $total_price = $total_price + $price_quan;
            //if($dataDet['is_purchase']!='1')
            //{
            $order_details .= "<tr>\n\t\t\t\t\t\t\t\t\t<td>" . $titleBrand . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $price_in . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $subtype . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $subscription_issues . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $todaysdate . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $end_date . "</td>\n\t\t\t\t\t\t\t\t\t<td>" . $dataDet['quntity'] . "</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan='3' align='left'>Sub Total: &#x20a6;" . $price_quan . "</td></tr>";
            //}
            //if($dataDet['is_purchase']!='1')
            //{
            //$quntity_price = $dataDet['quntity']*$price;
            //$order_details.= "<tr><td>".$titleBrand."</td><td>".$producturrency->currencyconverter($getCurrencyName,"NGN",$price)."</td><td>".$dataDet['quntity']."</td></tr><tr><td colspan='3' align='left'>Sub Total: &#x20a6;".@mumber_format($producturrency->currencyconverter($getCurrencyName,"NGN",$quntity_price),2)."</td></tr>";
            //}
        }
        $order_details .= "<tr><td colspan='3'>Total: " . $total_price . "</td></tr>";
        $order_details .= "</table>";
        $tempObj->delete('order_id="' . $orderIdForPurchase . '"');
        //echo $order_details;
        //exit;
        ###########################################  mail action ############################
        $userCompanyObj = new Company_Model_DbTable_Companies();
        $storage_company = new Zend_Auth_Storage_Session('company_type');
        $company_data = $storage_company->read();
        $storage = new Zend_Auth_Storage_Session('account_type');
        $data = $storage->read();
        if ($data->id) {
            $user_id = $data->id;
        } elseif ($company_data->id) {
            $user_id = $company_data->id;
        }
        $user_details = $userCompanyObj->fetchRow("id='" . $user_id . "'");
        $mailhost = SMTP_SERVER;
        $mailconfig = array('ssl' => SMTP_SSL, 'port' => SMTP_PORT, 'auth' => SMTP_AUTH, 'username' => SMTP_USERNAME, 'password' => SMTP_PASSWORD);
        $transport = new Zend_Mail_Transport_Smtp($mailhost, $mailconfig);
        Zend_Mail::setDefaultTransport($transport);
        $message = '<!DOCTYPE html>
				<html>
				<head>
				<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
				<meta charset="utf-8">
				<meta name="viewport" content="width=device-width,initial-scale=1.0">
				<title>Evendor</title>
				</head>
				<body style="font-family: \'Calibri\', arial;">
				<div id="container" style="width:80%; margin:0 auto;">
				<header id="heder">
				<div style="padding:15px 0px; background:#000000;"><a href="' . $this->view->serverUrl() . $this->view->baseUrl() . '/" target="_blank"><img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/images/logo.png" style="border:none;" alt="E-Vendor"></a></div>
				</header>
				<div style="background:#656565; padding:15px; min-height:200px;">
					<aside> 
						Hi ' . $user_details['first_name'] . ' ' . $user_details['last_name'] . ',<br/><br/>
						Your order has been successfully completed.Please check your order details.<br/><br/>
						' . $order_details . '<br/>Transaction message:' . $responseDescription . '
						<br/>Masked PAN:' . $pan . '<br/>Card Holder Name:' . $card_holder_name . '
						<br/>Transaction Date & Time:' . $tranDateTime . '<br/>
						
						<br/>Transactions reference number(MerchantTranID):' . $MerchantTranID . '<br/>
						<br/>Transaction Amount:' . $purchaseAmount . '<br/>
						<br/>Transaction Currency:' . $currency . '<br/>
						<br/>Authorization Code:' . $approvalCodeScr . '<br/>
						<br/>Merchant Name:Evendor<br/>
						<br/>Site Url:' . $this->view->serverUrl() . $this->view->baseUrl() . '<br/>
						<br/><br/><br/>
						Thank You<br/>
						Evendor 
					</aside>
				</div>

				<div style="background:#000000;  text-align:center; color:#FFFFFF; font-size:14px; padding:15px;">
				<br>
				&copy; Copyright ' . date("Y") . ' All Rights Reserved By Electronic Vendor Ltd.
				</div>

				</div>
				</body>
				</html>';
        ##############################  admin Message ###################################
        $message_admin = '<!DOCTYPE html>
				<html>
				<head>
				<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
				<meta charset="utf-8">
				<meta name="viewport" content="width=device-width,initial-scale=1.0">
				<title>Evendor</title>
				</head>
				<body style="font-family: \'Calibri\', arial;">
				<div id="container" style="width:80%; margin:0 auto;">
				<header id="heder">
				<div style="padding:15px 0px; background:#000000;"><a href="' . $this->view->serverUrl() . $this->view->baseUrl() . '/" target="_blank"><img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/images/logo.png" style="border:none;" alt="E-Vendor"></a></div>
				</header>
				<div style="background:#656565; padding:15px; min-height:200px;">
					<aside> 
						Hi,<br/><br/>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . ' has been successfully ordered.Please order details.<br/><br/>
						' . $order_details . '<br/>Transaction message:' . $responseDescription . '
						<br/>Transaction Date & Time:' . $tranDateTime . '<br/>
						
						<br/>Transactions reference number(MerchantTranID):' . $MerchantTranID . '<br/>
						<br/>Transaction Amount:' . $purchaseAmount . '<br/>
						<br/>Transaction Currency:' . $currency . '<br/>
						<br/>Authorization Code:' . $approvalCodeScr . '<br/>
						<br/>Merchant Name:Evendor<br/>
						<br/>Site Url:' . $this->view->serverUrl() . $this->view->baseUrl() . '<br/>
						<br/><br/><br/>
						Thank You<br/>
						Evendor 
					</aside>
				</div>

				<div style="background:#000000;  text-align:center; color:#FFFFFF; font-size:14px; padding:15px;">
				<br>
				&copy; Copyright ' . date("Y") . ' All Rights Reserved By Electronic Vendor Ltd.
				</div>

				</div>
				</body>
				</html>';
        ##################################################  end admin message #####################
        $mail = new Zend_Mail();
        $mail->addTo($user_details['user_email']);
        $mail->setSubject("Order Approved message.");
        $mail->setBodyHtml($message);
        $mail->setFrom(SETFROM, SETNAME);
        $mail->send();
        $mail = new Zend_Mail();
        $mail->addTo('*****@*****.**');
        $mail->setSubject("Order Approved message.");
        $mail->setBodyHtml($message_admin);
        $mail->setFrom(SETFROM, SETNAME);
        $mail->send();
        foreach ($new_product_array as $key => $pubVal) {
            $order_details_publisher = "<table cellpadding='1'>\n\t\t\t\t\t\t\t\t\t\t<tr><td>Item</td><td>Price</td><td>Quantity</td></tr>";
            foreach ($pubVal as $pub_order_det) {
                $productPriceInfo = $productPrice->getPriceByStoreId($pub_order_det['product_id'], $pub_order_det['store_id']);
                if ($pub_order_det['group_id'] != '' && $pub_order_det['group_id'] != 0) {
                    $arrayDataGroup = '';
                    $dateTime = date('Y-m-d H:i');
                    $price = $productPriceInfo['group_price'];
                } else {
                    $price = $productPriceInfo['price'];
                }
                $product_details = $this->modelBooks->fetchRow("id='" . $pub_order_det['product_id'] . "'");
                $getBrandInfo = $this->modelBooks->getBrandInfo($product_details['title']);
                if (!empty($getBrandInfo) && is_numeric($this->{$product_details}['title'])) {
                    $titleBrand = $getBrandInfo['brand'];
                } else {
                    $titleBrand = $product_details['title'];
                }
                if (!empty($product_details['parent_brand_id']) && $product_details['cat_id'] != '3') {
                    $productInfo = $this->modelBooks->fetchRow('id="' . $product_details['parent_brand_id'] . '"');
                    $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title);
                    if (!empty($getParentBrandInfo)) {
                        //$titleBrand=$titleBrand.' ('.$getParentBrandInfo['brand'].')';
                        $titleBrand = $getParentBrandInfo['brand'] . " - " . $titleBrand;
                    }
                }
                $getCurrencyName = $producturrency->getCurrencyCode($pub_order_det['store_id']);
                $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['author_id']);
                $imageInfo = $modelImage->getImageInfoByProductId($product_details['id']);
                if (count($subscription_data) > 0) {
                    if ($dataDet['group_id'] != '' && $dataDet['group_id'] != 0) {
                        $price_to_show = $subscription_data[0]->group_price_sub;
                    } else {
                        $price_to_show = $subscription_data[0]->individual_price;
                    }
                } else {
                    $price_to_show = $price;
                }
                if ($dataDet['user_type'] == "1") {
                    $finalsubprice = $price_to_show * $dataDet['quntity'];
                } else {
                    $finalsubprice = $price_to_show;
                }
                $quntity_price = $finalsubprice;
                $price_quan = $producturrency->currencyconverter($getCurrencyName, "NGN", $quntity_price);
                $price_in = $producturrency->currencyconverter($getCurrencyName, "NGN", $price_to_show);
                $total_price = $total_price + $price_quan;
                //if($dataDet['is_purchase']!='1')
                //{
                $order_details_publisher .= "<tr>\n\t\t\t\t\t\t\t\t\t\t<td>" . $titleBrand . "</td>\n\t\t\t\t\t\t\t\t\t\t<td>" . $price_in . "</td>\n\t\t\t\t\t\t\t\t\t\t<td>" . $pub_order_det['quntity'] . "</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td colspan='3' align='left'>Sub Total: &#x20a6;" . $price_quan . "</td></tr>";
            }
            $order_details_publisher .= "<tr><td colspan='3'>Total: " . $total_price . "</td></tr>";
            $order_details_publisher .= "</table>";
            $message_publisher = '<!DOCTYPE html>
				<html>
				<head>
				<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
				<meta charset="utf-8">
				<meta name="viewport" content="width=device-width,initial-scale=1.0">
				<title>Evendor</title>
				</head>
				<body style="font-family: \'Calibri\', arial;">
				<div id="container" style="width:80%; margin:0 auto;">
				<header id="heder">
				<div style="padding:15px 0px; background:#000000;"><a href="' . $this->view->serverUrl() . $this->view->baseUrl() . '/" target="_blank"><img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/images/logo.png" style="border:none;" alt="E-Vendor"></a></div>
				</header>
				<div style="background:#656565; padding:15px; min-height:200px;">
					<aside> 
						Hi Publisher,<br/><br/>User has been successfully ordered.Please order details.<br/><br/>
						' . $order_details_publisher . '<br/>Transaction message:' . $responseDescription . '
						<br/>Transaction Date & Time:' . $tranDateTime . '<br/>						
						<br/>Merchant Name:Evendor<br/>
						<br/>Site Url:' . $this->view->serverUrl() . $this->view->baseUrl() . '<br/>
						<br/><br/><br/>
						Thank You<br/>
						Evendor 
					</aside>
				</div>

				<div style="background:#000000;  text-align:center; color:#FFFFFF; font-size:14px; padding:15px;">
				<br>
				&copy; Copyright ' . date("Y") . ' All Rights Reserved By Electronic Vendor Ltd.
				</div>

				</div>
				</body>
				</html>';
            $mail = new Zend_Mail();
            $mail->addTo('*****@*****.**');
            $mail->setSubject("Order Approved message.");
            $mail->setBodyHtml($message_publisher);
            $mail->setFrom(SETFROM, SETNAME);
            $mail->send();
        }
        $this->_redirect('checkout/displayorder/orderid/' . $orderIdForPurchase);
        exit;
    }
Esempio n. 2
0
    public function approvedAction()
    {
        $producturrency = new Admin_Model_DbTable_Countries();
        $modelAuthor = new Publisher_Model_DbTable_Publishers();
        $tempObj = new Model_DbTable_Checkout();
        $creditHistoryObj = new User_Model_DbTable_Chistory();
        $transactionHistoryObj = new User_Model_DbTable_Transactionhistory();
        $this->modelBooks = new Publisher_Model_DbTable_Books();
        $modelImage = new Publisher_Model_DbTable_BookImages();
        $modelStore = new Admin_Model_DbTable_Countries();
        $productPrice = new Publisher_Model_DbTable_BookPrices();
        $productPrice = new Publisher_Model_DbTable_BookPrices();
        $groupSubsObj = new Company_Model_DbTable_GroupSubscriptions();
        $UsersubObj = new Model_DbTable_Usersubscription();
        $userCompanyObj = new Company_Model_DbTable_Companies();
        $response = $_POST['xmlmsg'];
        $xml_string = $_POST['xmlmsg'];
        $parsedxml = simplexml_load_string(stripslashes($response));
        //echo "<pre>";
        //print_r($parsedxml);
        $formDataTransApproved = array();
        foreach ($parsedxml as $RESPONSENODE) {
            //echo $RESPONSENODE."<br/>";
            if ($RESPONSENODE->getName() == 'OrderID') {
                $orderId = $RESPONSENODE;
                $orderIdForPurchase = $RESPONSENODE;
                $orderIdss = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'TransactionType') {
                $transactionType = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'PAN') {
                $pan = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'PurchaseAmountScr') {
                $purchaseAmount = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'TranDateTime') {
                $tranDateTime = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ResponseCode') {
                $responseCode = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ResponseDescription') {
                $responseDescription = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'OrderStatusScr') {
                $orderStatus = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ApprovalCode') {
                $approvalCode = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'MerchantTranID') {
                $merchantTranId = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'OrderDescription') {
                $orderDescription = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ApprovalCodeScr') {
                $approvalCodeScr = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'CurrencyScr') {
                $currency = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ThreeDSVerificaion') {
                $threeDsVerification = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'Brand') {
                $brandname = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'Name') {
                $card_holder_name = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'ThreeDSStatus') {
                $ThreeDSStatus = $RESPONSENODE;
            }
            if ($RESPONSENODE->getName() == 'MerchantTranID') {
                $MerchantTranID = $RESPONSENODE;
            }
        }
        $formDataTransApproved = array("orderId" => $orderId, "transactionType" => $transactionType, "pan" => $pan, "purchaseAmount" => $purchaseAmount, "tranDateTime" => $tranDateTime, "responseCode" => $responseCode, "responseDescription" => $responseDescription, "orderStatus" => $orderStatus, "approvalCode" => $approvalCode, "approvalCode" => $approvalCode, "merchantTranId" => $merchantTranId, "orderDescription" => $orderDescription, "approvalCodeScr" => $approvalCodeScr, "currency" => $currency, "brand" => $brandname, "card_holder_name" => $card_holder_name, "ThreeDSStatus" => $ThreeDSStatus, "threeDsVerification" => $threeDsVerification, "transaction_xml" => $xml_string);
        $inserted_id = $transactionHistoryObj->insert($formDataTransApproved);
        ##############  update table ###########################
        if ($orderStatus == 'APPROVED') {
            $orderSt = 1;
        } else {
            $orderSt = 0;
        }
        $tempTransactionUpdate = array("payment_status" => $orderSt, "transaction_id" => $inserted_id);
        //$tempObj->update($tempTransactionUpdate,'user_id="'.$user_id.'"');
        $creditHistoryObj->update($tempTransactionUpdate, "order_id='" . $orderId . "'");
        ##########################################################
        $total_price = '';
        $tempData = $tempObj->fetchAll("order_id='" . $orderId . "' and is_purchase!='1'");
        //$tempData = $tempObj->fetchAll("order_id='38115' and is_purchase!='1'");
        $css1 = ' style="text-align:center;padding:5px;word-wrap:break-word;color:#fff;max-width: 150px;" ';
        $order_details = "<table cellpadding='4' cellpadding='1' width='100%' style='background:#656565;;color:#fff;border-collapse:collapse;' border='1' BORDERCOLOR='#000'><tr><td colspan='9'>Your reference Id</td></tr><tr><td colspan='9'>Order ID:" . $orderId . "</td></tr><tr><td colspan='9'>Transaction ID:" . $inserted_id . "</td></tr><tr><td" . $css1 . ">Item Image</td><td" . $css1 . ">Title</td><td" . $css1 . ">Subscribed users</td><td" . $css1 . ">Price</td><td" . $css1 . ">Subscription Details</td><td" . $css1 . ">Number of Issues</td><td" . $css1 . ">Start Date</td><td" . $css1 . ">End Date</td><td" . $css1 . ">Quantity</td></tr>";
        $array_new = array();
        $new_product_array = array();
        foreach ($tempData as $dataDet) {
            $publication_det = $this->modelBooks->fetchRow("id='" . $dataDet['product_id'] . "'");
            if (@in_array($publication_det['publisher_id'], $array_new)) {
                $new_product_array[$publication_det['publisher_id']][] = array("id" => $dataDet['id'], "product_id" => $dataDet['product_id'], "user_id" => $dataDet['user_id'], "user_type" => $dataDet['user_type'], "store_id" => $dataDet['store_id'], "quntity" => $dataDet['quntity'], "group_id" => $dataDet['group_id'], "order_id" => $dataDet['group_id']);
            } else {
                array_push($array_new, $publication_det['publisher_id']);
                $new_product_array[$publication_det['publisher_id']][] = array("id" => $dataDet['id'], "product_id" => $dataDet['product_id'], "user_id" => $dataDet['user_id'], "user_type" => $dataDet['user_type'], "store_id" => $dataDet['store_id'], "quntity" => $dataDet['quntity'], "group_id" => $dataDet['group_id'], "order_id" => $dataDet['group_id']);
            }
        }
        $modelSubscription = new Publisher_Model_DbTable_Subscriptions();
        foreach ($tempData as $dataDet) {
            $order_idsids = $dataDet['order_id'];
            $user_ids_mail[] = $dataDet['user_id'];
            $productPriceInfo = $productPrice->getPriceByStoreId($dataDet['product_id'], $dataDet['store_id']);
            $subscription_data = $modelSubscription->fetchAll('id="' . $dataDet['subscription_type'] . '"');
            if ($dataDet['group_id'] != '' && $dataDet['group_id'] != 0) {
                $arrayDataGroup = '';
                $dateTime = date('Y-m-d H:i:s');
                $price = $productPriceInfo['group_price'];
                $arrayDataGroup = array("publication_id" => $dataDet['product_id'], "group_id" => $dataDet['group_id'], "company_id" => $dataDet['user_id'], "assigned_date" => $dateTime);
                $groupSubsObj->insert($arrayDataGroup);
            } else {
                $price = $productPriceInfo['price'];
            }
            $product_details = $this->modelBooks->fetchRow("id='" . $dataDet['product_id'] . "'");
            $getBrandInfo = $this->modelBooks->getBrandInfo($product_details['title']);
            if (!empty($getBrandInfo) && is_numeric($this->{$product_details}['title'])) {
                $titleBrand = $getBrandInfo['brand'];
            } else {
                $titleBrand = $product_details['title'];
            }
            if (!empty($product_details['parent_brand_id']) && $product_details['cat_id'] != '3') {
                $productInfo = $this->modelBooks->fetchRow('id="' . $product_details['parent_brand_id'] . '"');
                $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title);
                $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['publisher_id']);
                if (!empty($getParentBrandInfo)) {
                    //$titleBrand=$titleBrand.' ('.$getParentBrandInfo['brand'].')';
                    //$titleBrand=$getParentBrandInfo['brand']." - ".$titleBrand."<br/>".$authorInfo['publisher'];
                    $titleBrand = $getParentBrandInfo['brand'] . "<br/>" . $authorInfo['publisher'];
                }
            }
            $getCurrencyName = $producturrency->getCurrencyCode($dataDet['store_id']);
            $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['author_id']);
            $imageInfo = $modelImage->getImageInfoByProductId($product_details['id']);
            $sql1 = "update pclive_products set best_seller=best_seller+1 where id='" . $dataDet['product_id'] . "'";
            $result1 = $this->modelBooks->getAdapter()->query($sql1);
            $todaysdate = date('Y-m-d H:i:s');
            if ($dataDet['subscription_name'] == 'Weekly') {
                $date = new DateTime($todaysdate);
                $date->modify("+7 day");
                $end_date = $date->format("Y-m-d H:i:s");
            } else {
                if ($dataDet['subscription_name'] == 'Monthly') {
                    $date = new DateTime($todaysdate);
                    $date->modify("+30 day");
                    $end_date = $date->format("Y-m-d H:i:s");
                } else {
                    if ($dataDet['subscription_name'] == 'Quarterly') {
                        $date = new DateTime($todaysdate);
                        $date->modify("+90 day");
                        $end_date = $date->format("Y-m-d H:i:s");
                    } else {
                        if ($dataDet['subscription_name'] == 'Half Yearly') {
                            $date = new DateTime($todaysdate);
                            $date->modify("+182 day");
                            $end_date = $date->format("Y-m-d H:i:s");
                        } else {
                            if ($dataDet['subscription_name'] == 'Yearly') {
                                $date = new DateTime($todaysdate);
                                $date->modify("+365 day");
                                $end_date = $date->format("Y-m-d H:i:s");
                            }
                        }
                    }
                }
            }
            if (count($subscription_data) > 0) {
                $price_to_show = $dataDet['subscription_price'];
                $subtype = $dataDet['subscription_name'];
                $subscription_issues = $dataDet['subscription_issues'];
                $todaysdate = $todaysdate;
                $end_date = $end_date;
            } else {
                $price_to_show = $price;
                $subtype = "N/A";
                $subscription_issues = "N/A";
                $todaysdate = "N/A";
                $end_date = "N/A";
            }
            if ($dataDet['user_type'] == "1") {
                $finalsubprice = $price_to_show * $dataDet['quntity'];
            } else {
                $finalsubprice = $price_to_show;
            }
            if ($dataDet['group_id'] != '' && $dataDet['group_id'] != 0) {
                $subscriptiondatavalues = $UsersubObj->fetchAll('order_id=' . $dataDet['order_id'] . ' and product_id=' . $dataDet['product_id'] . '');
                $useremails = "";
                foreach ($subscriptiondatavalues as $userdata) {
                    $user_details = $userCompanyObj->fetchRow("id='" . $userdata['user_id'] . "'");
                    $useremails .= $user_details['user_email'] . ',';
                }
                $useremails = rtrim($useremails, ',');
            } else {
                $useremails = 'N/A';
            }
            $imageInfo = $modelImage->getImageInfoByProductId($dataDet['product_id']);
            $quntity_price = $finalsubprice;
            $price_quan = $producturrency->currencyconverter($getCurrencyName, "NGN", $quntity_price);
            $price_in = $producturrency->currencyconverter($getCurrencyName, "NGN", $price_to_show);
            $total_price = $total_price + $price_quan;
            //if($dataDet['is_purchase']!='1')
            //{
            $order_details .= '<tr>
									<td' . $css1 . '><img src="' . $this->view->serverUrl() . $this->view->baseUrl() . "/" . USER_UPLOAD_DIR . "thumb1_" . $imageInfo['image_name'] . '"></td>
									<td' . $css1 . '>' . $titleBrand . '</td>
									<td' . $css1 . '>' . $useremails . '</td>
									<td' . $css1 . '>' . $price_in . '</td>
									<td' . $css1 . '>' . $subtype . '</td>
									<td' . $css1 . '>' . $subscription_issues . '</td>
									<td' . $css1 . '>' . $todaysdate . '</td>
									<td' . $css1 . '>' . $end_date . '</td>
									<td' . $css1 . '>' . $dataDet['quntity'] . '</td>
								</tr>
								';
            //}
            //if($dataDet['is_purchase']!='1')
            //{
            //$quntity_price = $dataDet['quntity']*$price;
            //$order_details.= "<tr><td>".$titleBrand."</td><td>".$producturrency->currencyconverter($getCurrencyName,"NGN",$price)."</td><td>".$dataDet['quntity']."</td></tr><tr><td colspan='3' align='left'>Sub Total: &#x20a6;".@mumber_format($producturrency->currencyconverter($getCurrencyName,"NGN",$quntity_price),2)."</td></tr>";
            //}
        }
        $order_details .= '<tr><td colspan="6" align="left">&nbsp;</td><td colspan="2">Sub Total :</td><td> &#x20a6;' . $price_quan . '</td></tr>';
        $order_details .= "<tr><td colspan='6'>&nbsp;</td><td colspan='2' >Total : </td><td>" . $total_price . "</td></tr>";
        $order_details .= "</table>";
        $tempObj->delete('order_id="' . $orderIdForPurchase . '"');
        //echo $order_details;
        //exit;
        ###########################################  mail action ############################
        $userCompanyObj = new Company_Model_DbTable_Companies();
        $storage_company = new Zend_Auth_Storage_Session('company_type');
        $company_data = $storage_company->read();
        $storage = new Zend_Auth_Storage_Session('account_type');
        $data = $storage->read();
        if ($data->id) {
            $user_id = $data->id;
        } elseif ($company_data->id) {
            $user_id = $company_data->id;
        }
        $user_details = $userCompanyObj->fetchRow("id='" . $user_id . "'");
        $mailhost = SMTP_SERVER;
        $mailconfig = array('ssl' => SMTP_SSL, 'port' => SMTP_PORT, 'auth' => SMTP_AUTH, 'username' => SMTP_USERNAME, 'password' => SMTP_PASSWORD);
        $transport = new Zend_Mail_Transport_Smtp($mailhost, $mailconfig);
        Zend_Mail::setDefaultTransport($transport);
        $message = '<!DOCTYPE html> 
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <title>Evendor</title>
    </head>
    <body style="font-family: \'Calibri\', arial;">
        <div id="container" style="width:80%; margin:0 auto;">
            <header id="heder">
                <div style="padding:15px 0px; background:#000000; color:#fff;">
                    <a href="' . $this->view->serverUrl() . $this->view->baseUrl() . '/" target="_blank">
                        <img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/images/logo.png" style="border:none;" alt="E-Vendor">
                    </a>
                </div>
            </header>
            <div style="background:#656565; padding:15px; min-height:200px;color:#fff;">                 
                <span >Hi ' . $user_details['first_name'] . ' ' . $user_details['last_name'] . ',<br/><br/>
                Your order has been successfully completed.Please check your order details.<br><br></span>
                ' . $order_details . '<table border="0" cellpadding="5" style="background:#656565;color:#fff;width:100%;" width="100%"><tr><td colspan="2">Transaction message:' . $responseDescription . '</td></tr>
                <tr><td>Masked PAN:' . $pan . '</td><td>Card Holder Name:' . $card_holder_name . '</td></tr>
                <tr><td>Transaction Date & Time:' . $tranDateTime . '</td><td>Transactions reference number(MerchantTranID):' . $MerchantTranID . '</td></tr>
                <tr><td>Transaction Amount:' . $purchaseAmount . '</td><td>Transaction Currency:' . $currency . '</td></tr>
                <tr><td>Authorization Code:' . $approvalCodeScr . '</td><td>Merchant Name:Evendor</td></tr>
                <tr><td colspan="2">Site Url : <a style="color:#fff;text-decoration:none;" href="' . $this->view->serverUrl() . $this->view->baseUrl() . '">' . $this->view->serverUrl() . $this->view->baseUrl() . '</a></td></tr></table><br/>
                <br/><br/><br/>
                Thank You<br/><br/>
                Evendor                 
            </div>

            <div style="background:#000000;  text-align:center; color:#FFFFFF; font-size:14px; padding:15px;">                
                &copy; Copyright ' . date("Y") . ' All Rights Reserved By Electronic Vendor Ltd.
            </div>

        </div>
    </body>
</html>';
        if ($user_details['user_email'] != '') {
            $mail = new Zend_Mail();
            $mail->addTo($user_details['user_email']);
            //$mail->addTo('*****@*****.**');
            $mail->setSubject("Order Approved message.");
            $mail->setBodyHtml($message);
            $mail->setFrom(SETFROM, SETNAME);
            $mail->send();
        }
        ##############################  admin Message ###################################
        $message_admin = '<!DOCTYPE html>
				<html>
				<head>
				<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
				<meta charset="utf-8">
				<meta name="viewport" content="width=device-width,initial-scale=1.0">
				<title>Evendor</title>
				</head>
				<body style="font-family: \'Calibri\', arial;">
				<div id="container" style="width:80%; margin:0 auto;">
				<header id="heder">
				<div style="padding:15px 0px; background:#000000;"><a href="' . $this->view->serverUrl() . $this->view->baseUrl() . '/" target="_blank"><img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/images/logo.png" style="border:none;" alt="E-Vendor"></a></div>
				</header>
				<div style="background:#656565; padding:15px; min-height:200px;color:#fff;">
					Hi,<br/><br/>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . ' has been successfully ordered.Please see your order details.<br/><br/>
						' . $order_details . '<br/>Transaction message:' . $responseDescription . '
						<br/>Transaction Date & Time:' . $tranDateTime . '<br/>
						
						<br/>Transactions reference number(MerchantTranID):' . $MerchantTranID . '<br/>
						<br/>Transaction Amount:' . $purchaseAmount . '<br/>
						<br/>Transaction Currency:' . $currency . '<br/>
						<br/>Authorization Code:' . $approvalCodeScr . '<br/>
						<br/>Merchant Name:Evendor<br/>
						<br/>Site Url : <a style="color:#fff;" href="' . $this->view->serverUrl() . $this->view->baseUrl() . '">' . $this->view->serverUrl() . $this->view->baseUrl() . '</a><br/>
						<br/><br/><br/>
						Thank You<br/>
						Evendor 
				</div>

				<div style="background:#000000;  text-align:center; color:#FFFFFF; font-size:14px; padding:15px;">
				<br>
				&copy; Copyright ' . date("Y") . ' All Rights Reserved By Electronic Vendor Ltd.
				</div>

				</div>
				</body>
				</html>';
        //die($message_admin);
        ##################################################  end admin message #####################
        /*if ($user_details['user_email'] != '') {
              $mail = new Zend_Mail();
              //$mail->addTo($user_details['user_email']);
              $mail->addTo('*****@*****.**');
              $mail->setSubject("Order Approved message.");
              $mail->setBodyHtml($message);
              $mail->setFrom(SETFROM, SETNAME);
              $mail->send();
          }*/
        $get_registeration_id = mysql_query("select * from pclive_deviceID where user_publisher_id='" . $user_details['id'] . "' and reg_id!=''");
        while ($res_registeration_id = mysql_fetch_array($get_registeration_id)) {
            $reg = $res_registeration_id['reg_id'];
            $regID = array($reg);
            // $message="You have registerted successfully";
            $message = array("userID" => $user_details['id'], "msg" => "publication is ready to download", "email" => $user_details['user_email']);
            if ($res_registration_id['os_type'] == 0) {
                send_push_notification($regID, $message);
            } else {
                send_push_notification_ios($regID, $user_details['user_email'], $user_details['id'], "publication is ready to download");
            }
        }
        //$reg='APA91bEZVTcqtar_br_cipLae9TyYe26JhsE2jHHnV76K_zWSAAyly2ZW6SCd4-REMgY_lGtHLh-2VvObjlj-pRvHd2932KlKY7anEOKQMyviVLs1A1Y7RYDPNtXwuRqTY7rILdF_LcXvY4GntxKouBU1EUv8E1mCQ';
        if ($company_data->account_type == '1') {
            $subscriptiondatavalues = $UsersubObj->fetchAll('order_id=' . $orderId . ' and active_date IS NULL');
            foreach ($subscriptiondatavalues as $dataDetsubscribe) {
                $productdetails = $this->modelBooks->fetchRow("id='" . $dataDetsubscribe['product_id'] . "'");
                $getBrandInfo = $this->modelBooks->getBrandInfo($productdetails['title']);
                if (!empty($getBrandInfo) && is_numeric($productdetails['title'])) {
                    $titleBrand = $getBrandInfo['brand'];
                } else {
                    $titleBrand = $productdetails['title'];
                }
                if (!empty($productdetails['parent_brand_id']) && $productdetails['cat_id'] != '3') {
                    $productInfo = $this->modelBooks->fetchRow('id="' . $productdetails['parent_brand_id'] . '"');
                    $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title);
                    $authorInfo = $modelAuthor->getInfoByPublisherId($productdetails['publisher_id']);
                    if (!empty($getParentBrandInfo)) {
                        //$titleBrand=$titleBrand.' ('.$getParentBrandInfo['brand'].')';
                        //$titleBrand=$getParentBrandInfo['brand']." - ".$titleBrand."<br/>".$authorInfo['publisher'];
                        $titleBrand = $getParentBrandInfo['brand'] . "<br/>" . $authorInfo['publisher'];
                    }
                }
                $user_details_all = $userCompanyObj->fetchRow("id='" . $dataDetsubscribe['user_id'] . "'");
                $message1 = 'Hi ' . $user_details_all['first_name'] . ' ' . $user_details_all['last_name'] . ', you have been subscribed for the ' . $dataDetsubscribe['subscription_name'] . ' subscription for the product ' . $titleBrand . '  in evendor. You can download ' . $dataDetsubscribe['number_of_issues'] . ' issues. Your subscription starts from ' . $dataDetsubscribe['start_date'] . ' and ends on ' . $dataDetsubscribe['end_date'] . '.Please see your order details.<br/><br/>
				' . $order_details . '';
                if ($user_details_all['user_email'] != '') {
                    $mail = new Zend_Mail();
                    $mail->addTo($user_details_all['user_email']);
                    //$mail->addTo('*****@*****.**');
                    $mail->setSubject("Order Approved message.");
                    $mail->setBodyHtml($message1);
                    $mail->setFrom(SETFROM, SETNAME);
                    $mail->send();
                }
                /* $mail = new Zend_Mail();
                   $mail->addTo('*****@*****.**');
                   $mail->setSubject("Order Approved message.");
                   $mail->setBodyHtml($message1);
                   $mail->setFrom(SETFROM, SETNAME);
                   $mail->send(); */
                $get_registeration_id = mysql_query("select * from pclive_deviceID where user_publisher_id='" . $user_details_all['id'] . "' and reg_id!=''");
                while ($res_registeration_id = mysql_fetch_array($get_registeration_id)) {
                    $reg = $res_registeration_id['reg_id'];
                    $regID = array($reg);
                    // $message="You have registerted successfully";
                    $message = array("userID" => $user_details_all['id'], "msg" => "publication is ready to download", "email" => $user_details_all['user_email']);
                    if ($res_registration_id['os_type'] == 0) {
                        send_push_notification($regID, $message);
                    } else {
                        send_push_notification_ios($regID, $user_details['user_email'], $user_details['id'], "publication is ready to download");
                    }
                    //send_push_notification($regID, $message);
                }
                //$reg='APA91bEZVTcqtar_br_cipLae9TyYe26JhsE2jHHnV76K_zWSAAyly2ZW6SCd4-REMgY_lGtHLh-2VvObjlj-pRvHd2932KlKY7anEOKQMyviVLs1A1Y7RYDPNtXwuRqTY7rILdF_LcXvY4GntxKouBU1EUv8E1mCQ';
                /* $reg='APA91bFkjucY1iaCcNprgfIZ_ajoQLv_Ky_jGIH8Y83a3by9fO_ych0yMqG7v9PpJzgttzzbwWZ5SOv6QQV1uYocH4OlyaAsPPi4vvOJILk9YVaVsx2xItJ83_0gXsVDM71LosYKoAqHpdQVx9hXuY5RGXr3LJuzWg';
                
                                  $regID = array($reg);
                                  // $message="You have registerted successfully";
                                  $message = array("userID" =>$user_details_all['id'],"msg" =>"publication is ready to download","email" =>$user_details_all['user_email'],);
                                  send_push_notification($regID, $message); */
            }
        }
        foreach ($new_product_array as $key => $pubVal) {
            $order_details_publisher = "<table cellpadding='1' width='100%' style='background:#656565;color:#fff;'>\n\t\t\t\t\t\t\t\t\t\t<tr><td>Item</td><td>Price</td><td>Quantity</td></tr>";
            foreach ($pubVal as $pub_order_det) {
                $productPriceInfo = $productPrice->getPriceByStoreId($pub_order_det['product_id'], $pub_order_det['store_id']);
                if ($pub_order_det['group_id'] != '' && $pub_order_det['group_id'] != 0) {
                    $arrayDataGroup = '';
                    $dateTime = date('Y-m-d H:i');
                    $price = $productPriceInfo['group_price'];
                } else {
                    $price = $productPriceInfo['price'];
                }
                $product_details = $this->modelBooks->fetchRow("id='" . $pub_order_det['product_id'] . "'");
                $getBrandInfo = $this->modelBooks->getBrandInfo($product_details['title']);
                if (!empty($getBrandInfo) && is_numeric($this->{$product_details}['title'])) {
                    $titleBrand = $getBrandInfo['brand'];
                } else {
                    $titleBrand = $product_details['title'];
                }
                if (!empty($product_details['parent_brand_id']) && $product_details['cat_id'] != '3') {
                    $productInfo = $this->modelBooks->fetchRow('id="' . $product_details['parent_brand_id'] . '"');
                    $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title);
                    if (!empty($getParentBrandInfo)) {
                        //$titleBrand=$titleBrand.' ('.$getParentBrandInfo['brand'].')';
                        //$titleBrand=$getParentBrandInfo['brand']." - ".$titleBrand;
                        $titleBrand = $getParentBrandInfo['brand'];
                    }
                }
                $getCurrencyName = $producturrency->getCurrencyCode($pub_order_det['store_id']);
                $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['author_id']);
                $imageInfo = $modelImage->getImageInfoByProductId($product_details['id']);
                if (count($subscription_data) > 0) {
                    if ($dataDet['group_id'] != '' && $dataDet['group_id'] != 0) {
                        $price_to_show = $subscription_data[0]->group_price_sub;
                    } else {
                        $price_to_show = $subscription_data[0]->individual_price;
                    }
                } else {
                    $price_to_show = $price;
                }
                if ($dataDet['user_type'] == "1") {
                    $finalsubprice = $price_to_show * $dataDet['quntity'];
                } else {
                    $finalsubprice = $price_to_show;
                }
                $quntity_price = $finalsubprice;
                $price_quan = $producturrency->currencyconverter($getCurrencyName, "NGN", $quntity_price);
                $price_in = $producturrency->currencyconverter($getCurrencyName, "NGN", $price_to_show);
                $total_price = $total_price + $price_quan;
                //if($dataDet['is_purchase']!='1')
                //{
                $order_details_publisher .= "<tr>\n\t\t\t\t\t\t\t\t\t\t<td>" . $titleBrand . "</td>\n\t\t\t\t\t\t\t\t\t\t<td>" . $price_in . "</td>\n\t\t\t\t\t\t\t\t\t\t<td>" . $pub_order_det['quntity'] . "</td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td colspan='3' align='left'>Sub Total: &#x20a6;" . $price_quan . "</td></tr>";
            }
            $order_details_publisher .= "<tr><td colspan='3'>Total: " . $total_price . "</td></tr>";
            $order_details_publisher .= "</table>";
            $message_publisher = '<!DOCTYPE html>
				<html>
				<head>
				<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
				<meta charset="utf-8">
				<meta name="viewport" content="width=device-width,initial-scale=1.0">
				<title>Evendor</title>
				</head>
				<body style="font-family: \'Calibri\', arial;">
				<div id="container" style="width:80%; margin:0 auto;">
				<header id="heder">
				<div style="padding:15px 0px; background:#000000;"><a href="' . $this->view->serverUrl() . $this->view->baseUrl() . '/" target="_blank"><img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/public/css/default/images/logo.png" style="border:none;" alt="E-Vendor"></a></div>
				</header>
				<div style="background:#656565; padding:15px; min-height:200px;color:#fff;">
					Hi Publisher,<br/><br/>User has been successfully ordered.Please review order details.<br/><br/>
						' . $order_details . '<br/>Transaction message:' . $responseDescription . '
						<br/>Transaction Date & Time:' . $tranDateTime . '<br/>						
						<br/>Merchant Name:Evendor<br/>
						<br/>Site Url : <a style="color:#fff;" href="' . $this->view->serverUrl() . $this->view->baseUrl() . '">' . $this->view->serverUrl() . $this->view->baseUrl() . '</a><br/>
						<br/><br/><br/>
						Thank You<br/>
						Evendor
				</div>

				<div style="background:#000000;  text-align:center; color:#FFFFFF; font-size:14px; padding:15px;">
				<br>
				&copy; Copyright ' . date("Y") . ' All Rights Reserved By Electronic Vendor Ltd.
				</div>

				</div>
				</body>
				</html>';
            // die($message_publisher);
            $mail = new Zend_Mail();
            $mail->addTo('*****@*****.**');
            //$mail->addTo('*****@*****.**');
            $mail->setSubject("Order Approved message.");
            $mail->setBodyHtml($message_publisher);
            $mail->setFrom(SETFROM, SETNAME);
            $mail->send();
        }
        $this->_redirect('checkout/displayorder/orderid/' . $orderIdForPurchase);
        exit;
    }