| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | 
							- <?php
 
-     session_start();
 
-     if (!isset($_SESSION['hash_user'])) {
 
-         header('Location: login.php');
 
-         exit;
 
-     }
 
- ?>  
 
- <?php
 
-     $form_id = $_GET['formulario'];
 
-     header('Content-Type: text/csv; charset=utf-8');
 
-     header('Content-Disposition: attachment; filename='.$form_id.'.csv');
 
-     require_once('../controller/forms.php');
 
-     $total_rows = get_total_rows($form_id);
 
-     $res_data = get_records_pagination($form_id, 0, $total_rows);
 
-     $output = fopen('php://output', 'w');
 
-     
 
-     $all_fields = array('id');
 
-     foreach($res_data as $form) {
 
-         foreach($form as $key => $val) {
 
-             if(!in_array($key, $all_fields)) {
 
-                 $all_fields[] = $key;
 
-             }
 
-         }
 
-     }
 
-     fputcsv($output, $all_fields);
 
-     foreach($res_data as $form) {
 
-         $prepared = array();
 
-         $prepared[] = $form->id;
 
-         foreach($all_fields as $field) {
 
-             if ($field == 'id') continue;
 
-             
 
-             if ($field === 'timestamp') {
 
-                 $prepared[] = date("H:i:s d/m/Y", $form->$field);
 
-                 continue;
 
-             }
 
-             if (isset($form->$field)) $prepared[] = $form->$field;
 
-             else $prepared[] = '';
 
-             
 
-         }
 
-         fputcsv($output, $prepared);
 
-     }
 
- ?>
 
 
  |