public function createPdf() { $salesPersonId = JFactory::getSession()->get('salesPersonId'); //$filter = JRequest::getVar('filter', array('name' => "", 'code' => "", 'merchant_id' => "", 'fromdate' => "", 'todate' => "")); //$filter = JRequest::getVar('filter',array(),'post','array'); $currency_prefix = JModel::getInstance('setting', 'enmasseModel')->getCurrencyPrefix(); $dealList = JModel::getInstance('deal', 'enmasseModel')->searchBySaleReports($salesPersonId, JRequest::getVar('name'), JRequest::getVar('merchant_id'), JRequest::getVar('fromdate'), JRequest::getVar('todate'), JRequest::getVar('code')); if (empty($dealList)) { return null; } $result = '<table style="border:1px dotted #D5D5D5; border-collapse: collapse;"><tr valign="middle"><th style="border:1px dotted #D5D5D5;" align="center" width="50">' . JText::_("No") . '</th><th style="border:1px dotted #D5D5D5;" width="150">' . JText::_("Deal Code") . '</th><th style="border:1px dotted #D5D5D5;" width="150">' . JText::_("Deal Name") . '</th><th style="border:1px dotted #D5D5D5;" width="100">' . JText::_("Merchant") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Qty Sold") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Unit Price") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Total Sales") . '</th></tr>'; $i = 0; foreach ($dealList as $row) { $i++; $merchant_name = JModel::getInstance('merchant', 'enmasseModel')->retrieveName($row->merchant_id); $total_sales = $row->price * $row->cur_sold_qty; $result .= '<tr> <td style="border:1px dotted #D5D5D5;" align="center">' . $i . '</td> <td style="border:1px dotted #D5D5D5;">' . $row->deal_code . '</td> <td style="border:1px dotted #D5D5D5;">' . $row->name . '</td> <td style="border:1px dotted #D5D5D5;">' . $merchant_name . '</td> <td style="border:1px dotted #D5D5D5;" align="center">' . $row->cur_sold_qty . '</td> <td style="border:1px dotted #D5D5D5;" align="center">' . $currency_prefix . $row->price . '</td> <td style="border:1px dotted #D5D5D5;" align="center">' . $currency_prefix . $total_sales . '</td></tr>'; $total_amount += $total_sales; } $result .= '<tr><td style="border:1px dotted #D5D5D5;" colspan="6" style="text-align:right" >Total Amount: </td> <td style="border:1px dotted #D5D5D5;" align="center">' . $currency_prefix . $total_amount . '</td></tr></table>'; //todo require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_enmasse' . DS . 'helpers' . DS . 'html2pdf' . DS . 'html2pdf.class.php'; $html2pdf = new HTML2PDF('P', 'A4', 'en'); $html2pdf->setDefaultFont('Arial'); $html2pdf->writeHTML($result); $outFileName = 'report-' . DatetimeWrapper::getDateOfNow() . '.pdf'; $html2pdf->Output($outFileName, 'I'); die; }
$price = $price * $cartItem->getCount(); // currencty to be default as GBP if it's not set in payment configuration $currency = "GBP"; if (isset($this->attributeConfig->CURRENCY) && trim($this->attributeConfig->CURRENCY) != "") { $currency = $this->attributeConfig->CURRENCY; } // account to be "internet" if it's not set in payment configuration $account = "internet"; if (isset($this->attributeConfig->ACCOUNT) && trim($this->attributeConfig->ACCOUNT) != "") { $account = $this->attributeConfig->ACCOUNT; } $merchantId = $this->attributeConfig->MERCHANT_ID; $secret = $this->attributeConfig->SECRET; $orderId = $this->orderId; // time stamp $timestamp = DatetimeWrapper::getDateOfNow('YmdHis'); // hash value $hash = sha1($timestamp . "." . $merchantId . "." . $orderId . "." . $price . "." . $currency); $doubleHash = sha1($hash . "." . $secret); // store the hash into session $session =& JFactory::getSession(); $session->set("realExHash", $doubleHash); // not used $returnUrl = JURI::root() . 'index.php?option=com_enmasse&controller=payment&task=notifyUrl&payClass=realex'; ?> <form name="paymentForm" action="https://epage.payandshop.com/epage.cgi" method="post"> <input type="hidden" name="MERCHANT_ID" value="<?php echo $merchantId; ?>
public static function pdf() { $filter = JRequest::getVar('filter', array('name' => "", 'code' => "", 'merchant_id' => "", 'fromdate' => "", 'todate' => "")); $dealList = JModel::getInstance('salereports', 'enmasseModel')->search($filter['code'], $filter['name'], $filter['saleperson_id'], $filter['merchant_id'], $filter['fromdate'], $filter['todate']); $currency = JModel::getInstance('setting', 'enmasseModel')->getCurrencyPrefix(); if (empty($dealList)) { $msg = JText::_("NO_SALE_REPORT"); JFactory::getApplication()->redirect("index.php?option=com_enmasse&controller=saleReports", $msg, 'notice'); return false; } $result = '<table style="border:1px dotted #D5D5D5; border-collapse: collapse;"><tr valign="middle"><th style="border:1px dotted #D5D5D5;" align="center" width="30">' . JText::_("No") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Deal Code") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Deal Name") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="60">' . JText::_("Merchant") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="60">' . JText::_("Qty Sold") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Unit Price") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Total Sales") . '</th><th style="border:1px dotted #D5D5D5;" align="center" width="80">' . JText::_("Commission Percentage") . '</th><th style="border:1px dotted #D5D5D5;" align="left" width="150">' . JText::_("Total Commission Amount") . '</th></tr>'; $i = 0; $total_commission_amount = 0; foreach ($dealList as $row) { $i++; $merchant_name = JModel::getInstance('merchant', 'enmasseModel')->retrieveName($row->merchant_id); $total_sales = $row->price * $row->cur_sold_qty; $total_amount = $total_sales * $row->commission_percent / 100; $result .= '<tr> <td style="border:1px dotted #D5D5D5;" align="center">' . $i . '</td> <td style="border:1px dotted #D5D5D5;">' . $row->deal_code . '</td> <td style="border:1px dotted #D5D5D5;">' . $row->name . '</td> <td style="border:1px dotted #D5D5D5;">' . $merchant_name . '</td> <td style="border:1px dotted #D5D5D5;" align="center">' . $row->cur_sold_qty . '</td> <td style="border:1px dotted #D5D5D5;" align="center">' . $currency . $row->price . '</td> <td style="border:1px dotted #D5D5D5;" align="center">' . $currency . $total_sales . '</td> <td style="border:1px dotted #D5D5D5;" align="center">' . $row->commission_percent . ' % </td> <td style="border:1px dotted #D5D5D5;" align="center">' . $currency . $total_amount . '</td></tr>'; $total_commission_amount += $total_amount; } $result .= '<tr><td style="border-right:1px dotted #D5D5D5; text-align:right" colspan="8" >Total: </td> <td style="border:1px dotted #D5D5D5;" align="center" align="center">' . $currency . $total_commission_amount . '</td></tr></table>'; //todo require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_enmasse' . DS . 'helpers' . DS . 'html2pdf' . DS . 'html2pdf.class.php'; $html2pdf = new HTML2PDF('P', 'A4', 'en'); $html2pdf->setDefaultFont('Arial'); $html2pdf->writeHTML($result); $outFileName = 'report-' . DatetimeWrapper::getDateOfNow() . '.pdf'; $html2pdf->Output($outFileName, 'I'); header("Content-type:application/pdf"); // It will be called downloaded.pdf header("Content-Disposition:attachment;filename=downloaded.pdf"); die; }