Commit c2364888 authored by Monish Deb's avatar Monish Deb

CSV export fatal error fix

parent 306ef748
......@@ -82,11 +82,10 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
ft.trxn_id AS trxn_id,
cov.label AS payment_instrument,
ft.check_number,
CASE
WHEN eftc.entity_table = 'civicrm_contribution'
THEN c.source
ELSE cgp.label
END AS source,
c.source AS source,
c.id AS contribution_id,
c.contact_id AS contact_id,
eb.batch_id AS batch_id,
ft.currency AS currency,
cov_status.label AS status,
CASE
......@@ -150,7 +149,7 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
*/
function formatHeaders($values) {
$arrayKeys = array_keys($values);
$headers = '';
$headers = [];
if (!empty($arrayKeys)) {
foreach ($values[$arrayKeys[0]] as $title => $value) {
$headers[] = $title;
......@@ -220,4 +219,71 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
function exportTRANS() {
}
/**
* Generate CSV array for export.
*
* @param array $export
*/
public function makeExport($export) {
// getting data from admin page
$prefixValue = Civi::settings()->get('contribution_invoice_settings');
foreach ($export as $batchId => $dao) {
$financialItems = array();
$this->_batchIds = $batchId;
$queryResults = array();
while ($dao->fetch()) {
$creditAccountName = $creditAccountType = $creditAccount = NULL;
if ($dao->credit_account) {
$creditAccountName = $dao->credit_account_name;
$creditAccountType = $dao->credit_account_type_code;
$creditAccount = $dao->credit_account;
}
else {
$creditAccountName = $dao->from_credit_account_name;
$creditAccountType = $dao->from_credit_account_type_code;
$creditAccount = $dao->from_credit_account;
}
$invoiceNo = CRM_Utils_Array::value('invoice_prefix', $prefixValue) . "" . $dao->contribution_id;
$financialItems[] = array(
'Batch ID' => $dao->batch_id,
'Invoice No' => $invoiceNo,
'Contact ID' => $dao->contact_id,
'Financial Trxn ID/Internal ID' => $dao->financial_trxn_id,
'Transaction Date' => $dao->trxn_date,
'Debit Account' => $dao->to_account_code,
'Debit Account Name' => $dao->to_account_name,
'Debit Account Type' => $dao->to_account_type_code,
'Debit Account Amount (Unsplit)' => $dao->debit_total_amount,
'Transaction ID (Unsplit)' => $dao->trxn_id,
'Debit amount (Split)' => $dao->amount,
'Payment Instrument' => $dao->payment_instrument,
'Check Number' => $dao->check_number,
'Source' => $dao->source,
'Currency' => $dao->currency,
'Transaction Status' => $dao->status,
'Amount' => $dao->amount,
'Credit Account' => $creditAccount,
'Credit Account Name' => $creditAccountName,
'Credit Account Type' => $creditAccountType,
'Item Description' => $dao->item_description,
);
end($financialItems);
$queryResults[] = get_object_vars($dao);
}
CRM_Utils_Hook::batchItems($queryResults, $financialItems);
$financialItems['headers'] = self::formatHeaders($financialItems);
self::export($financialItems);
}
parent::initiateDownload();
}
}
......@@ -4,11 +4,10 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
{foreach from=$grantPayment key=key item=data}
<body >
{foreach from=$grantPayment key=key item=data}
<!-- Stub 1 -->
<div style="height:300px; font-size: 11px;">
<div style="font-size: 11px;">
<div style="float:right; text-align:right;">{$data.payment_id}</div>
<table width="100%" cellpadding=0 cellspacing=0 style="font-size: 11px;">
<tr><td width="100%" colspan="4">RE: {$data.payment_reason}</td></tr>
......@@ -64,6 +63,6 @@
</tr>
</table>
</div>
{/foreach}
</body>
{/foreach}
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment