Example #1
0
 /**
  * Gets a CSV export of all the users in this waiting room.
  *
  * @return \League\Csv\ $csv
  */
 public function getCSVExport()
 {
     $data = [];
     $competitions = $this->competitions;
     array_push($data, ['competition id']);
     foreach ($competitions as $competition) {
         array_push($data, [$competition->id]);
     }
     return build_csv($data);
 }
Example #2
0
 /**
  * Build and export a CSV of user data.
  *
  * @param  object $users
  * @return \League\Csv
  */
 public function exportUsersCsv($users)
 {
     $data = [];
     $data[] = ['Northstar ID', 'First Name', 'Last Name', 'Email', 'Mobile Number', 'Reportback Admin Link', 'Reported Quantity', '# Promoted', '# Approved', '# Excluded', '# Flagged', '# Pending', 'Why Participated', 'Caption for latest Reportback Item'];
     foreach ($users as $user) {
         $details = [$user->id, isset($user->first_name) ? $user->first_name : '', isset($user->last_name) ? $user->last_name : '', isset($user->email) ? $user->email : '', isset($user->mobile) ? $user->mobile : ''];
         if (isset($user->reportback)) {
             $details[] = reportback_admin_url($user->reportback->id);
             $details[] = $user->reportback->quantity;
             $details[] = $user->reportback->reportback_items->count_by_status['promoted'];
             $details[] = $user->reportback->reportback_items->count_by_status['approved'];
             $details[] = $user->reportback->reportback_items->count_by_status['excluded'];
             $details[] = $user->reportback->reportback_items->count_by_status['flagged'];
             $details[] = $user->reportback->reportback_items->count_by_status['pending'];
             $details[] = $user->reportback->why_participated;
             $details[] = array_pop($user->reportback->reportback_items->data)->caption;
         }
         $data[] = $details;
     }
     return build_csv($data);
 }
Example #3
0
 // at least one record found
 $pages_number = get_pages_number($results_number, $records_per_page);
 // get the total number of pages
 $sql = build_select_part($fields_labels_ar, $table_name);
 if ($where_clause != "") {
     $sql .= " WHERE {$where_clause}";
 }
 // end if
 if (isset($export_to_csv) && $export_to_csv == 1 && $export_to_csv_feature == 1) {
     if (isset($csv_creation_time_limt)) {
         set_time_limit($csv_creation_time_limt);
     }
     // end if
     // execute the select without limit query for csv
     $res_records_csv = $db->send_query($sql);
     $csv = build_csv($res_records_csv, $fields_labels_ar);
     ob_end_clean();
     $db->free_result($res_records_csv);
     header("Content-Type: text/x-csv");
     header('Content-Disposition: attachment; filename="' . $table_name . '.csv"');
     echo $csv;
     exit;
 }
 // end if
 if (!isset($order)) {
     // get the first field present in the results form as order
     $count_temp = 0;
     $fields_labels_ar_count = count($fields_labels_ar);
     while (!isset($order) && $count_temp < $fields_labels_ar_count) {
         if ($fields_labels_ar[$count_temp]["present_results_search_field"] === '1') {
             $order = $fields_labels_ar[$count_temp]["name_field"];