diff options
author | Sashi20 | 2023-01-06 18:55:48 +0530 |
---|---|---|
committer | GitHub | 2023-01-06 18:55:48 +0530 |
commit | ba175403e1e38e890417ac8ae14ce7712fc59cd0 (patch) | |
tree | cbf42eb34b3b3e11ae2f9cbaa51e852cffcfa413 | |
parent | e50ea22b17a234bdda73a840727c5fc713f68875 (diff) | |
parent | 4501a215fbc6139fcb84cabe157aa560cd597d82 (diff) | |
download | fellowship_testimonials-ba175403e1e38e890417ac8ae14ce7712fc59cd0.tar.gz fellowship_testimonials-ba175403e1e38e890417ac8ae14ce7712fc59cd0.tar.bz2 fellowship_testimonials-ba175403e1e38e890417ac8ae14ce7712fc59cd0.zip |
Merge pull request #12 from Sashi20/master
Add page to download participant details
-rwxr-xr-x | fellowship_testimonials.module | 32 | ||||
-rw-r--r-- | vle_registration.inc | 106 |
2 files changed, 136 insertions, 2 deletions
diff --git a/fellowship_testimonials.module b/fellowship_testimonials.module index 93210b1..5ba25b1 100755 --- a/fellowship_testimonials.module +++ b/fellowship_testimonials.module @@ -1,7 +1,7 @@ <?php -/*error_reporting(E_ALL); +error_reporting(E_ALL); ini_set('display_errors', TRUE); -ini_set('display_startup_errors', TRUE);*/ +ini_set('display_startup_errors', TRUE); function fellowship_testimonials_menu() { $items = array(); /*$items["fellowship-testimonials"] = array( @@ -56,6 +56,24 @@ ini_set('display_startup_errors', TRUE);*/ "type" => MENU_NORMAL_ITEM, "file" => 'vle_registration.inc' ); + + $items["animation-hackathon/view/registrations"] = array( + "title" => "All India 2D Animation Hackathon Registered particpants", + "page callback" => "view_animation_hackathon_vle_registrations", + /*"page arguments" => "",**/ + "access arguments" => array("Manage Animation Hackathon registration"), + "type" => MENU_NORMAL_ITEM, + "file" => 'vle_registration.inc' + ); + $items["animation-hackathon/view/registrations/download"] = array( + "title" => "All India 2D Animation Hackathon Registered particpants", + "page callback" => "download_registration_details", + /*"page arguments" => "",**/ + "access arguments" => array("Manage Animation Hackathon registration"), + "type" => MENU_NORMAL_ITEM, + "file" => 'vle_registration.inc' + ); + return $items; } @@ -72,6 +90,10 @@ ini_set('display_startup_errors', TRUE);*/ "Animation Hackathon registration" => array( "title" => t("Animation Hackathon registration"), 'restrict access' => TRUE + ), + "Manage Animation Hackathon registration" => array( + "title" => t("Manage Animation Hackathon registration"), + 'restrict access' => TRUE ) ); } @@ -214,4 +236,10 @@ function _hackathon_list_of_cities($state=Null, $district=NULL) } } return $csc_block_name; +} + + +function vle_registration_csv_path() +{ + return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'data/'; }
\ No newline at end of file diff --git a/vle_registration.inc b/vle_registration.inc index 55cd4d8..6c076af 100644 --- a/vle_registration.inc +++ b/vle_registration.inc @@ -463,4 +463,110 @@ function animation_hackathon_vle_registration_form_submit($form, &$form_state){ drupal_set_message('Registration successful', 'status'); } } +} + + +function view_animation_hackathon_vle_registrations() { + $page_content = ""; + + $query = db_select('animation_hackathon_vle_registration'); + $query->fields('animation_hackathon_vle_registration'); + $result = $query->execute(); + $page_content .= "Total number of registrations: " . $result->rowCount() . "<br>Click <a href='registrations/download'>here</a> to download the CSV with participant details"; + return $page_content; + } + + + function download_registration_details(){ + global $user; + /* get pending submissions to be approved */ + if ($user->uid == 0) + { + $msg = drupal_set_message(t('It is mandatory to login on this website to download the email IDs of the participants. If you are new user please create a new account first.'), 'error'); + //drupal_goto('/pssp'); + drupal_goto('user/login', array('query' => drupal_get_destination())); + return $msg; + } + $root_path = vle_registration_csv_path(); + $my_submission_rows = array(); + $query = db_select('animation_hackathon_vle_registration'); + $query->fields('animation_hackathon_vle_registration'); + $all_submissions_q = $query->execute(); + $participants_email_id_file = $root_path . "participants.csv"; + $fp = fopen($participants_email_id_file, "w"); + /* making the first row */ + $item = array( + "Country", + "State", + "District", + "Block", + "CSC ID", + "Team size", + "Team member 1 Name", + "Team member 1 Email", + "Team member 1 Contact", + "Team member 1 Gender", + "Team member 1 Category", + "Team member 1 Institution", + "Team member 2 Name", + "Team member 2 Email", + "Team member 2 Contact", + "Team member 2 Gender", + "Team member 2 Category", + "Team member 2 Institution", + "Know Synfig", + "Other Softwares used", + "How did you come to know about the event?", + "About team", + "Date of registration" + ); + fputcsv($fp, $item); + + while($row = $all_submissions_q->fetchObject()) { + $item = array( + $row->country, + $row->state, + $row->district, + $row->block_name, + $row->csc_id, + $row->team_size, + $row->team_member_1_name, + $row->team_member_1_email, + $row->team_member_1_contact, + $row->team_member_1_gender, + $row->team_member_1_category, + $row->team_member_1_institution, + $row->team_member_2_name, + $row->team_member_2_email, + $row->team_member_2_contact, + $row->team_member_2_gender, + $row->team_member_2_category, + $row->team_member_2_institution, + $row->know_synfig, + $row->other_softwares_used, + $row->information_about_event, + $row->about_team, + date("d-m-Y", $row->registration_timestamp) + ); + fputcsv($fp, $item); + } + fclose($fp); + if($participants_email_id_file){ + ob_clean(); + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: public"); + header("Content-Description: File Transfer"); + header('Content-Type: application/csv'); + header('Content-disposition: attachment; filename=participant-details.csv'); + header('Content-Length:' . filesize($participants_email_id_file)); + header("Content-Transfer-Encoding: binary"); + header('Expires: 0'); + header('Pragma: no-cache'); + readfile($participants_email_id_file); + /*ob_end_flush(); + ob_clean(); + flush();*/ + } }
\ No newline at end of file |