} function download_it($report_condition_KEY, $export_KEY, $date) { global $DIA; # update report with new since date $s['value'] = date('Y-m-d H:i:s', strtotime($date)); $s['key'] = $report_condition_KEY; $DIA->save('report_condition', $s); # #update export table with new request $e['Status'] = 'Active'; $e['key'] = $export_KEY; $DIA->save('export', $e); } $last = get_export($export_KEY); $rec = get_export($rec_export_KEY); if ($_GET['action'] == 'donation') { download_it($report_condition_KEY, $export_KEY, $last['Last_Run']); } if ($_GET['action'] == 'rec') { download_it($rec_report_condition_KEY, $rec_export_KEY, $rec['Last_Run']); } ?> <h2>Donation Report</h2> You last downloaded <a href="<?php echo SALSA_HQ_LIST; ?> lists/<?php
Route::get('send', function () { return View::make('form_sent'); }); Route::get('/csv', function () { $table = Order::all(); $output = ""; foreach ($table as $row) { $output .= '"'; $output .= implode('","', $row->toArray()); $output .= "\"\n"; } $headers = array('Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="ExportFileName.csv"'); return Response::make(rtrim($output, "\n"), 200, $headers); }); Route::get('/csv2', function () { get_export(); }); /** * get_export * saved to public folder * * @access public * @return void */ function get_export() { $table = Order::all(); $file = fopen('file.csv', 'w'); foreach ($table as $row) { fputcsv($file, $row->toarray()); }