diff --git a/agent/income.php b/agent/income.php index 183b8097..9f0cd5d8 100644 --- a/agent/income.php +++ b/agent/income.php @@ -146,13 +146,27 @@ $summary_total_income = floatval($row['total_income']);

Income

- = 2) { ?>
- + = 2) { ?> +
+ + + +
+ + +
-
diff --git a/agent/modals/income/income_export.php b/agent/modals/income/income_export.php new file mode 100644 index 00000000..2cf2b3c5 --- /dev/null +++ b/agent/modals/income/income_export.php @@ -0,0 +1,174 @@ + + + +
+ + + + + +
+ + 0) { + $delimiter = ","; + $enclosure = '"'; + $escape = '\\'; // backslash + $filename = sanitizeFilename($file_name_prepend . "Income-" . date('Y-m-d_H-i-s') . ".csv"); + + //create a file pointer + $f = fopen('php://memory', 'w'); + + //set column headers + $fields = array('Date', 'Type', 'Source', 'Description', 'Client', 'Amount', 'Currency', 'Payment Method', 'Reference', 'Account'); + fputcsv($f, $fields, $delimiter, $enclosure, $escape); + + //output each row of the data, format line as csv and write to file pointer + while ($row = mysqli_fetch_assoc($sql)) { + $lineData = array($row['income_date'], $row['income_type'], $row['income_source'], $row['income_description'], $row['income_client'], $row['income_amount'], $row['income_currency_code'], $row['income_method'], $row['income_reference'], $row['income_account']); + fputcsv($f, array_map('escapeCsvFormula', $lineData), $delimiter, $enclosure, $escape); + } + + //move back to beginning of file + fseek($f, 0); + + //set headers to download file rather than displayed + header('Content-Type: text/csv'); + header('Content-Disposition: attachment; filename="' . $filename . '";'); + + //output all remaining data on a file pointer + fpassthru($f); + } + + logAudit("Income", "Export", "$session_name exported $num_rows income record(s) to CSV file"); + + exit; + +}