function getInvoiceDetail($order_id, $pg_nm, $payPerAd = 1) { if (empty($order_id)) { return; } $mainframe = JFactory::getApplication(); $site = $mainframe->getCfg('sitename'); require JPATH_SITE . DS . "administrator" . DS . "components" . DS . "com_socialads" . DS . "config" . DS . "config.php"; $db = JFactory::getDBO(); $query = "SELECT p.id as order_id,p.`ad_id`,p.mdate,p.ad_amount,p.transaction_id,p.status,p.processor,p.payee_id,u.username,u.id, u.email\n\t\tFROM #__ad_payment_info as p, #__users as u\n\t\t\tWHERE p.payee_id=u.id\n\t\t\tAND p.id=" . $order_id; $db->setQuery($query); $orderDetails = $db->loadObject(); $body = JText::_('PAY_PAYMENT_BODY'); $socialadshelper = new socialadshelper(); // GET USER ID FOR BILL INFO //$userId = $socialadshelper->getOrderUserId($order_id); //GET BILL INFO JLoader::import('buildad', JPATH_SITE . DS . 'components' . DS . 'com_socialads' . DS . 'models'); $socialadsModelBuildad = new socialadsModelBuildad(); $billinfo = $socialadsModelBuildad->getbillDetails($orderDetails->id); // DEFINE ORDER STATUS if ($orderDetails->status == 'C') { $orderstatus = JText::_('ADS_INVOICE_STATUS_COMPLEATE'); } else { if ($orderDetails->status == 'P') { $orderstatus = JText::_('ADS_INVOICE_STATUS_PENDING'); } else { if ($orderDetails->status == 'E') { $orderstatus = JText::_('ADS_INVOICE_STATUS_COMPLEATE_ERROR_OCCURED'); } else { $orderstatus = JText::_('ADS_INVOICE_AMOUNT_CANCELLED'); } } } $inv_adver_Html = ""; $sa_displayblocks = array(); // if ad wallet if ($payPerAd == 0) { $sa_displayblocks = array('invoiceDetail' => 1, 'billingDetail' => 0, 'adsDetail' => 0); } $billpath = $socialadshelper->getViewpath('payment', 'invoice'); ob_start(); include $billpath; $inv_adver_Html = ob_get_contents(); ob_end_clean(); //----------------------------- jimport('joomla.utilities.utility'); global $mainframe; $app = JFactory::getApplication(); $mainframe = JFactory::getApplication(); $sitelink = JUri::root(); $manageAdLink = "<a href='" . $sitelink . "administrator" . DS . "index.php?option=com_socialads&view=approveads' targe='_blank'>" . JText::_("COM_SOCIALADS_EMAIL_THIS_LINK") . "</a>"; // GET config details $frommail = $mainframe->getCfg('mailfrom'); $fromname = $mainframe->getCfg('fromname'); $adTitle = $socialadshelper->getAdTitle($orderDetails->ad_id); $siteName = $mainframe->getCfg('sitename'); $today = date('Y-m-d H:i:s'); if (empty($orderDetails->payee_id)) { // return payee id not found return; } $user = JFactory::getUser($orderDetails->payee_id); $adUserName = $user->username; $recipient = $user->email; $displayOrderid = sprintf("%05s", $order_id); // if paper mode if ($payPerAd == 1) { $approve_msg = JText::_("COM_SOCIALADS_INVOICE_MAIL_ADMIN_APPROCE_NO_MSG"); if ($socialads_config['approval'] == 1) { $approve_msg = JText::_("COM_SOCIALADS_INVOICE_MAIL_ADMIN_APPROCE_YES_MSG"); } // FOR ADVERTISER INVICE AND ORDER CONFIRM MAIL $advertiserEmailBody = JText::_("COM_SOCIALADS_INVOICE_MAIL_CONTENT"); // NOW find & REPLACE TAG $find = array('[SEND_TO_NAME]', '[ADVERTISER_NAME]', '[SITENAME]', '[SITELINK]', '[ADTITLE]', '[CONTENT]', '[TIMESTAMP]', '[ORDERID]', '[ADMIN_APPROVAL_MSG]'); $replace = array($adUserName, $adUserName, $siteName, $sitelink, $adTitle, $content, $today, $displayOrderid, $approve_msg); $advertiserEmailBody = str_replace($find, $replace, $advertiserEmailBody); $advertiserEmailBody = $advertiserEmailBody . "<br> <br>" . $inv_adver_Html; $subject = JText::sprintf('ADS_INVOICE_MAIL_SUB', $displayOrderid); $status = $socialadshelper->sendmail($recipient, $subject, $advertiserEmailBody, '', 0, ""); // -------------- ADMIN INVOICE MAIL COPY -------------------- $adminEmailBody = JText::_("COM_SOCIALADS_INVOICE_MAIL_CONTENT_ADMIN_COPY"); $orderPrice = $orderDetails->ad_amount . " " . $socialads_config["currency"]; $admin_approve_msg = ''; //!$app->isAdmin() && $admin_approve_msg = ''; if ($socialads_config['approval'] == 1) { $admin_approve_msg = JText::sprintf("COM_SOCIALADS_APPRVE_MAIL_TO_ADMIN_ADD_MSG", $manageAdLink); } $find = array('[SEND_TO_NAME]', '[ADVERTISER_NAME]', '[SITENAME]', '[VALUE]', '[ORDERID]', '[ADMIN_APPROVAL_MSG]'); $replace = array($fromname, $adUserName, $siteName, $orderPrice, $displayOrderid, $admin_approve_msg); $adminEmailBody = str_replace($find, $replace, $adminEmailBody); $adminEmailBody = $adminEmailBody . "<br> <br>" . $inv_adver_Html; $subject = JText::sprintf('COM_SOCIALADS_INVOICE_MAIL_ADVERTISER_ADMIN_SUBJECT', $displayOrderid); $status = $socialadshelper->sendmail($frommail, $subject, $adminEmailBody, '', 0, ""); } else { // ADVERTISER MAIL $advertiserEmailBody = JText::_("COM_SOCIALADS_WALLET_ADDED_BALACE_ADVETISER_EMAIL"); // NOW find & REPLACE TAG $find = array('[SEND_TO_NAME]', '[SITENAME]', '[ORDERID]'); $replace = array($adUserName, $siteName, $displayOrderid); $advertiserEmailBody = str_replace($find, $replace, $advertiserEmailBody); $advertiserEmailBody = $advertiserEmailBody . "<br> <br>" . $inv_adver_Html; $subject = JText::sprintf('COM_SOCIALADS_WALLET_ADDED_BALACE_ADVETISER_EMAIL_SUBJECT', $displayOrderid); $status = $socialadshelper->sendmail($recipient, $subject, $advertiserEmailBody, '', 0, ""); // ADMIN INVOICE MAIL COPY $adminEmailBody = JText::_("COM_SOCIALADS_INVOICE_MAIL_CONTENT_ADMIN_COPY"); $orderPrice = $orderDetails->ad_amount . " " . $socialads_config["currency"]; $find = array('[SEND_TO_NAME]', '[ADVERTISER_NAME]', '[SITENAME]', '[VALUE]', '[ORDERID]', '[ADMIN_APPROVAL_MSG]'); $replace = array($fromname, $adUserName, $siteName, $orderPrice, $displayOrderid, ''); $adminEmailBody = str_replace($find, $replace, $adminEmailBody); $adminEmailBody = $adminEmailBody . "<br> <br>" . $inv_adver_Html; $subject = JText::sprintf('COM_SOCIALADS_INVOICE_MAIL_ADVERTISER_ADMIN_SUBJECT', $displayOrderid); $status = $socialadshelper->sendmail($frommail, $subject, $adminEmailBody, '', 0, ""); // ad wallet mode } }