diff --git a/application/controllers/admin/participants.php b/application/controllers/admin/participants.php index 4b67fe1b4b8..0424b5f2ffa 100644 --- a/application/controllers/admin/participants.php +++ b/application/controllers/admin/participants.php @@ -197,6 +197,26 @@ function editShareInfo() 'shared_uid' => $this->input->post('shared_uid')); $this->participant_shares_model->updateShare($data); } +function delParticipant() +{ + + $this->load->model('participants_model'); + $selectoption = $this->input->post('selectedoption'); + $participant_id = $this->input->post('participant_id'); + if($selectoption=="po") + { + $this->participants_model->deleteParticipant($participant_id); + } + elseif($selectoption=="ptt") + { + $this->participants_model->deleteParticipantToken($participant_id); + } + else + { + $this->participants_model->deleteParticipantTokenAnswer($participant_id); + } + +} /* * This function is resposible for editing data on the jqGrid */ @@ -224,7 +244,6 @@ function editParticipant() } if($operation == 'edit') { - $data = array( 'participant_id' => $_POST['id'], 'firstname' => $_POST['firstname'], @@ -235,10 +254,6 @@ function editParticipant() 'owner_uid' => $oid); $this->participants_model->updateRow($data); } - elseif($operation == 'del') - { - $this->participants_model->deleteRow($_POST); - } elseif($operation == 'add') { $uuid = $this->gen_uuid(); @@ -954,8 +969,7 @@ function attributeMapCSV() $errorinupload = array('error' => $this->upload->display_errors()); $this->session->unset_userdata('summary'); $data = array( 'errorinupload' => $errorinupload); - - $this->session->set_userdata('summary',$data); + $this->session->set_userdata('summary',$data); self::_getAdminHeader(); $clang = $this->limesurvey_lang; $data = array('clang'=> $clang); @@ -1459,6 +1473,61 @@ function attributeMapToken() $this->load->view('admin/Participants/attributeMapToken_view',$data); self::_getAdminFooter("http://docs.limesurvey.org", $this->limesurvey_lang->gT("LimeSurvey online manual")); } - +function isValidGuid($guid) +{ + return (!empty($guid) && preg_match('/^\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/', $guid)); +} +function blacklistParticipant() + { + $this->load->model('participants_model'); + $participant_id = $this->uri->segment(4); + $survey_id = $this->uri->segment(5); + $clang = $this->limesurvey_lang; + if(!is_numeric($survey_id)) + { + $blacklist = $this->uri->segment(5); + if($blacklist=='Y' || $blacklist =='N') + { + $data = array('blacklisted' => $blacklist,'participant_id' => $participant_id ); + $result = $this->participants_model->blacklistparticipantglobal($data); + $result['global'] = 1; + $result['clang'] = $clang; + $result['blacklist'] = $blacklist; + $this->load->view('admin/Participants/blacklist_view',$result); + } + else + { + $result['is_participant']=0; + $result['is_updated']=0; + $result['clang'] = $clang; + $this->load->view('admin/Participants/blacklist_view',$result); + } + } + else + { + $blacklist = $this->uri->segment(6); + if( $blacklist=='Y' || $blacklist =='N') + { + $data = array('blacklisted' => $blacklist); + $result = $this->participants_model->blacklistparticipantlocal($data,$survey_id,$participant_id);$result['global'] = 1; + $result['clang'] = $clang; + $result['local'] = 1; + $result['blacklist'] = $blacklist; + $this->load->view('admin/Participants/blacklist_view',$result); + + } + else + { + $result['is_participant']=0; + $result['is_updated']=0; + $result['clang'] = $clang; + $this->load->view('admin/Participants/blacklist_view',$result); + + } + + } + + + } } ?> diff --git a/application/controllers/admin/tokens.php b/application/controllers/admin/tokens.php index ad084b93e62..a4b3989a60f 100644 --- a/application/controllers/admin/tokens.php +++ b/application/controllers/admin/tokens.php @@ -748,6 +748,7 @@ function email($surveyid,$tokenids=null) $attributes=GetTokenFieldsAndNames($surveyid); $tokenoutput=""; + if ($emcount > 0) { foreach ($emresult->result_array() as $emrow) @@ -789,6 +790,7 @@ function email($surveyid,$tokenids=null) } else { + echo "dfsA"; $fieldsarray["{OPTOUTURL}"]="".htmlspecialchars("$publicurl/optout.php?lang=".trim($emrow['language'])."&sid=$surveyid&token={$emrow['token']}").""; if ( $modrewrite ) { diff --git a/application/controllers/admin/user.php b/application/controllers/admin/user.php index b2d4884382b..f5dff698c79 100644 --- a/application/controllers/admin/user.php +++ b/application/controllers/admin/user.php @@ -60,7 +60,7 @@ function editusers() //$uresult = db_execute_assoc($uquery); //Checked $uresult = $this->users_model->getSomeRecords(array("users_name"),array("uid"=>$usrhimself['parent_id'])); $srow = $uresult->row_array(); - //$usersummary .= "{$srow['users_name']}\n"; + //$usersummary .= "{$srow['users_name']}\n"; } $data['usrhimself']=$usrhimself; @@ -136,13 +136,13 @@ function adduser() db_execute_assoc($template_query); //Checked // add new user to userlist - $squery = "SELECT uid, users_name, password, parent_id, email, create_survey, configurator, create_user, delete_user, superadmin, manage_template, manage_label FROM ".$this->db->dbprefix('users')." WHERE uid='{$newqid}'"; //added by Dennis + $squery = "SELECT uid, users_name, password, parent_id, email, create_survey, configurator, create_user, delete_user, participant_panel,superadmin, manage_template, manage_label FROM ".$this->db->dbprefix('users')." WHERE uid='{$newqid}'"; //added by Dennis $sresult = db_execute_assoc($squery);//Checked $srow = $sresult->row_array(); $userlist = getuserlist(); array_push($userlist, array("user"=>$srow['users_name'], "uid"=>$srow['uid'], "email"=>$srow['email'], "password"=>$srow["password"], "parent_id"=>$srow['parent_id'], // "level"=>$level, - "create_survey"=>$srow['create_survey'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], + "create_survey"=>$srow['create_survey'],"participant_panel"=>$srow['participant_panel'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], "delete_user"=>$srow['delete_user'], "superadmin"=>$srow['superadmin'], "manage_template"=>$srow['manage_template'], "manage_label"=>$srow['manage_label'])); @@ -564,6 +564,7 @@ function userrights() // Forbids Allowing more privileges than I have if(isset($_POST['create_survey']) && $this->session->userdata('USER_RIGHT_CREATE_SURVEY'))$rights['create_survey']=1; else $rights['create_survey']=0; + if(isset($_POST['participant_panel']) && $this->session->userdata('USER_RIGHT_PARTICIPANT_PANEL'))$rights['participant_panel']=1; else $rights['participant_panel']=0; if(isset($_POST['configurator']) && $this->session->userdata('USER_RIGHT_CONFIGURATOR'))$rights['configurator']=1; else $rights['configurator']=0; if(isset($_POST['create_user']) && $this->session->userdata('USER_RIGHT_CREATE_USER'))$rights['create_user']=1; else $rights['create_user']=0; if(isset($_POST['delete_user']) && $this->session->userdata('USER_RIGHT_DELETE_USER'))$rights['delete_user']=1; else $rights['delete_user']=0; @@ -583,6 +584,7 @@ function userrights() if(isset($_POST['create_survey']))$rights['create_survey']=1; else $rights['create_survey']=0; if(isset($_POST['configurator']))$rights['configurator']=1; else $rights['configurator']=0; if(isset($_POST['create_user']))$rights['create_user']=1; else $rights['create_user']=0; + if(isset($_POST['participant_panel']))$rights['participant_panel']=1; else $rights['participant_panel']=0; if(isset($_POST['delete_user']))$rights['delete_user']=1; else $rights['delete_user']=0; // Only Initial Superadmin can give this right @@ -593,7 +595,7 @@ function userrights() // Initial SuperAdmin has parent_id == 0 $adminquery = "SELECT uid FROM ".$this->db->dbprefix("users")." WHERE parent_id=0"; $adminresult = db_select_limit_assoc($adminquery, 1); - $row=$adminresult->FetchRow(); + $row=$adminresult->row_array(); if($row['uid'] == $this->session->userdata('loginID')) // it's the original superadmin !!! { diff --git a/application/core/AdminController.php b/application/core/AdminController.php index cdf919d0b67..6aecece149d 100644 --- a/application/core/AdminController.php +++ b/application/core/AdminController.php @@ -320,7 +320,7 @@ function _GetSessionUserRights($loginID) { //$squery = "SELECT create_survey, configurator, create_user, delete_user, superadmin, manage_template, manage_label FROM {$dbprefix}users WHERE uid=$loginID"; $this->load->model("Users_model"); - $query = $this->Users_model->getSomeRecords(array("create_survey, configurator, create_user, delete_user, superadmin, manage_template, manage_label"),array("uid"=>$loginID)); + $query = $this->Users_model->getSomeRecords(array("create_survey, configurator, create_user, delete_user, superadmin,participant_panel, manage_template, manage_label"),array("uid"=>$loginID)); //$sresult = db_execute_assoc($squery); //Checked //if ($sresult->RecordCount()>0) if($query->num_rows() > 0) @@ -328,8 +328,9 @@ function _GetSessionUserRights($loginID) //$fields = $sresult->FetchRow(); $fields = $query->row_array(); $this->session->set_userdata('USER_RIGHT_CREATE_SURVEY', $fields['create_survey']); + $this->session->set_userdata('USER_RIGHT_PARTICIPANT_PANEL', $fields['participant_panel']); $this->session->set_userdata('USER_RIGHT_CONFIGURATOR', $fields['configurator']); - $this->session->set_userdata('USER_RIGHT_CREATE_USER', $fields['create_user']); + $this->session->set_userdata('USER_RIGHT_CREATE_USER', $fields['create_user']); $this->session->set_userdata('USER_RIGHT_DELETE_USER', $fields['delete_user']); $this->session->set_userdata('USER_RIGHT_SUPERADMIN', $fields['superadmin']); $this->session->set_userdata('USER_RIGHT_MANAGE_TEMPLATE', $fields['manage_template']); diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php index b744209754f..789a3946c28 100644 --- a/application/helpers/common_helper.php +++ b/application/helpers/common_helper.php @@ -1484,11 +1484,11 @@ function getuserlist($outputformat='fullinfoarray') { if ($srow['uid'] != $CI->session->userdata('loginID')) { - $userlist[] = array("user"=>$srow['users_name'], "uid"=>$srow['uid'], "email"=>$srow['email'], "password"=>$srow['password'], "full_name"=>$srow['full_name'], "parent_id"=>$srow['parent_id'], "create_survey"=>$srow['create_survey'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], "delete_user"=>$srow['delete_user'], "superadmin"=>$srow['superadmin'], "manage_template"=>$srow['manage_template'], "manage_label"=>$srow['manage_label']); //added by Dennis modified by Moses + $userlist[] = array("user"=>$srow['users_name'], "uid"=>$srow['uid'], "email"=>$srow['email'], "password"=>$srow['password'], "full_name"=>$srow['full_name'], "parent_id"=>$srow['parent_id'], "create_survey"=>$srow['create_survey'], "participant_panel"=>$srow['participant_panel'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], "delete_user"=>$srow['delete_user'], "superadmin"=>$srow['superadmin'], "manage_template"=>$srow['manage_template'], "manage_label"=>$srow['manage_label']); //added by Dennis modified by Moses } else { - $userlist[0] = array("user"=>$srow['users_name'], "uid"=>$srow['uid'], "email"=>$srow['email'], "password"=>$srow['password'], "full_name"=>$srow['full_name'], "parent_id"=>$srow['parent_id'], "create_survey"=>$srow['create_survey'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], "delete_user"=>$srow['delete_user'], "superadmin"=>$srow['superadmin'], "manage_template"=>$srow['manage_template'], "manage_label"=>$srow['manage_label']); + $userlist[0] = array("user"=>$srow['users_name'], "uid"=>$srow['uid'], "email"=>$srow['email'], "password"=>$srow['password'], "full_name"=>$srow['full_name'], "parent_id"=>$srow['parent_id'], "create_survey"=>$srow['create_survey'],"participant_panel"=>$srow['participant_panel'], "configurator"=>$srow['configurator'], "create_user"=>$srow['create_user'], "delete_user"=>$srow['delete_user'], "superadmin"=>$srow['superadmin'], "manage_template"=>$srow['manage_template'], "manage_label"=>$srow['manage_label']); } } else @@ -3912,6 +3912,7 @@ function setuserrights($uid, $rights) $CI->load->helper("database"); $updates = "create_survey=".$rights['create_survey'] . ", create_user=".$rights['create_user'] + . ", participant_panel=".$rights['participant_panel'] . ", delete_user=".$rights['delete_user'] . ", superadmin=".$rights['superadmin'] . ", configurator=".$rights['configurator'] diff --git a/application/models/participants_model.php b/application/models/participants_model.php index 8006dbb8f39..ae5c22845aa 100644 --- a/application/models/participants_model.php +++ b/application/models/participants_model.php @@ -33,24 +33,84 @@ function updateRow($data) $this->db->where('participant_id',$data['participant_id']); $this->db->update('participants',$data); } +function deleteParticipantTokenAnswer($rows) +{ + $rowid=explode(",",$rows); + //$rowid = array('243148a0-bf56-4ee1-a6d2-a1f1cb5243d5'); + foreach($rowid as $row) + { + $this->db->where('participant_id',$row); + $tokens = $this->db->get('survey_links'); + foreach($tokens->result_array() as $key => $value) + { + $this->db->where('participant_id',$row); + $this->db->delete('participants'); //Delete from participants + if($this->db->table_exists('tokens_'.$value['survey_id'])) + { + $this->db->select('token'); + $this->db->where('participant_id',$value['participant_id']); + $tokenid = $this->db->get('tokens_'.$value['survey_id']); + $token = $tokenid->row(); + if($this->db->table_exists('survey_'.$value['survey_id'])) + { + if(!empty($token->token)) + { + $this->db->where('token',$tokenid->row()->token); + $gettoken=$this->db->get('survey_'.$value['survey_id']); + $this->db->where('token',$gettoken->row()->token); + $this->db->delete('survey_'.$value['survey_id']); + } + } + $this->db->where('participant_id',$value['participant_id']); + $this->db->delete('tokens_'.$value['survey_id']);// Deletes from token + } + } + } + +} +function deleteParticipantToken($rows) +{ + $rowid=explode(",",$rows); + foreach($rowid as $row) + { + $this->db->where('participant_id',$row); + $tokens = $this->db->get('survey_links'); + foreach($tokens->result_array() as $key => $value) + { + if($this->db->table_exists('tokens_'.$value['survey_id'])) + { + $this->db->where('participant_id',$value['participant_id']); + $this->db->delete('tokens_'.$value['survey_id']); + } + } + $this->db->where('participant_id',$row); + $this->db->delete('participants'); + $this->db->where('participant_id',$row); + $this->db->delete('survey_links'); + $this->db->where('participant_id',$row); + $this->db->delete('participant_attribute'); + } + +} /* * This function deletes the row marked in the navigator * Parameters : row id's * Return Data : None */ -function deleteRow($rows) +function deleteParticipant($rows) { // Converting the comma seperated id's to an array to delete multiple rows - $rowid=explode(",",$rows['id']); - foreach($rowid as $row) + $rowid=explode(",",$rows); + foreach($rowid as $row) { $this->db->where('participant_id',$row); $this->db->delete('participants'); $this->db->where('participant_id',$row); - $this->db->delete('participant_shares'); + $this->db->delete('survey_links'); $this->db->where('participant_id',$row); $this->db->delete('participant_attribute'); } + } /* * This function is responsible for adding the participant to the database from the CSV upload @@ -1143,6 +1203,45 @@ function copytosurveyatt($surveyid,$mapped,$newcreate) $returndata = array('success'=>$sucessfull,'duplicate'=>$duplicate); return $returndata; } +function blacklistparticipantglobal($data) +{ + $this->db->where('participant_id',$data['participant_id']); + $this->db->get('participants'); + $is_participant = $this->db->affected_rows(); + $this->db->where('participant_id',$data['participant_id']); + $this->db->update('participants', $data); + $is_updated = $this->db->affected_rows(); + $result = array('is_participant' => $is_participant, + 'is_updated' => $is_updated ); + return $result; + +} +function blacklistparticipantlocal($data,$survey_id,$tid) +{ + $is_survey = $this->db->table_exists('tokens_'.$survey_id); + if($is_survey) + { + $this->db->where('tid',$tid); + $this->db->get('tokens_'.$survey_id); + $is_participant = $this->db->affected_rows(); + $this->db->where('tid',$tid); + $this->db->update('tokens_'.$survey_id, $data); + $is_updated = $this->db->affected_rows(); + $result = array('is_participant' => $is_participant, + 'is_updated' => $is_updated, + 'is_survey' => $is_survey); + } + else + { + $is_survey = $this->db->table_exists('tokens_'.$survey_id); + $is_participant = ""; + $is_updated=""; + $result = array('is_participant' => $is_participant, + 'is_updated' => $is_updated, + 'is_survey' => $is_survey); + } + return $result; +} } ?> diff --git a/application/views/admin/Participants/blacklist_view.php b/application/views/admin/Participants/blacklist_view.php new file mode 100644 index 00000000000..d5180613e6c --- /dev/null +++ b/application/views/admin/Participants/blacklist_view.php @@ -0,0 +1,115 @@ + + + + +" /> +<?PHP echo $clang->gT("Blacklist Control") ?> +" /> + + +" /> + + + +
+ + + - +
+ + + + + + + + + + +
+
+

Blacklist Control

+

+
+
+
+
+

+gT("You have successfully blacklisted from any survey on this server"); + } + else if($blacklist == 'N') + { + echo $clang->gT("You have successfully un-blacklisted from any survey on this server"); + } + } + else if($is_participant) + { + if($blacklist == 'Y') + { + echo $clang->gT("You have already been blacklisted from any survey on this server"); + } + else if($blacklist == 'N') + { + echo $clang->gT("You have already been un-blacklisted from any survey on this server"); + } + + } + else if(!$is_survey) + { + echo $clang->gT("Survey is no longer active"); + } + else + { + echo $clang->gT("The URL you are trying to use is either modified, or you have been removed from this server"); + } + +} +else if($local == 1) +{ + if($is_participant && $is_updated) + { + if($blacklist == 'Y') + { + echo $clang->gT("You have successfully blacklisted from this survey"); + } + else if($blacklist == 'N') + { + echo $clang->gT("You have successfully un-blacklisted from this survey"); + } + } + else if($is_participant) + { + if($blacklist == 'Y') + { + echo $clang->gT("You have already been blacklisted from this survey"); + } + else if($blacklist == 'N') + { + echo $clang->gT("You have already been un-blacklisted from this survey"); + } + + } + else + { + echo $clang->gT("The URL you are trying to use is either modified, or you have been removed from this server"); + + } + +} +else +{ + echo $clang->gT("You have successfully blacklisted from this survey"); +} +?> +

+
+ + diff --git a/application/views/admin/Participants/displayParticipants_view.php b/application/views/admin/Participants/displayParticipants_view.php index f4549c3fb39..cb1c7475d7a 100644 --- a/application/views/admin/Participants/displayParticipants_view.php +++ b/application/views/admin/Participants/displayParticipants_view.php @@ -1,7 +1,6 @@ " /> -" /> " /> " /> " /> @@ -16,6 +15,7 @@ + gT("Next") ?>"; var error = "gT("Error") ?>"; var exportcsv = "gT("Export CSV") ?>"; +var nooptionselected = "gT("Please choose either of the options") ?>"; var removecondition = "gT("Remove Condition") ?>"; var selectSurvey = "gT("Please select a survey to add participants to"); ?>"; var cancelBtn = "gT("Cancel") ?>"; var exportBtn = "gT("Export") ?>"; var okBtn = "gT("OK") ?>"; +var deleteMsg = "
  1. Delete Participant from central table only
  2. Delete Participant from central table and token table
  3. Delete Participant from central table, token table and from results as well
"; var searchBtn = "gT("Search") ?>"; var shareMsg = "gT("You can see and edit settings for shared participant in share panel.") ?>"; //PLEASE REVIEW var jsonUrl = ""; @@ -91,6 +93,7 @@ var editUrl = ""; var minusbutton = ""; var addbutton = ""; +var delparticipantUrl = ""; var surveylinkUrl = ""; var getAttribute_json = ""; var exporttocsv = ""; @@ -257,6 +260,5 @@ ?> - diff --git a/application/views/admin/Super/adminmenu.php b/application/views/admin/Super/adminmenu.php index 8bc6a96f150..61e56f2756b 100644 --- a/application/views/admin/Super/adminmenu.php +++ b/application/views/admin/Super/adminmenu.php @@ -1,3 +1,4 @@ +
', '_top')" />
diff --git a/installer/sql/create-mssql.sql b/installer/sql/create-mssql.sql index 76f1f286e2e..54e60f8f71b 100644 --- a/installer/sql/create-mssql.sql +++ b/installer/sql/create-mssql.sql @@ -382,6 +382,7 @@ CREATE TABLE [prefix_users] ( [email] VARCHAR(320) NOT NULL UNIQUE, [create_survey] TINYINT NOT NULL default '0', [create_user] TINYINT NOT NULL default '0', + [participant_panel] TINYINT NOT NULL default '0', [delete_user] TINYINT NOT NULL default '0', [superadmin] TINYINT NOT NULL default '0', [configurator] TINYINT NOT NULL default '0', @@ -404,8 +405,74 @@ CREATE TABLE [prefix_templates_rights] ( [use] int NOT NULL, PRIMARY KEY ([uid],[folder]) ); - - +-- +-- Table structure for table participants +-- +CREATE TABLE [prefix_participants] ( + [participant_id] varchar(50) NOT NULL, + [firstname] varchar(40) NOT NULL, + [lastname] varchar(40) NOT NULL, + [email] varchar(80) NOT NULL, + [language] varchar(2) NOT NULL, + [blacklisted] varchar(1) NOT NULL, + [owner_uid] int(20) NOT NULL, + PRIMARY KEY ([participant_id]) +); +-- +-- Table structure for table participant attribute +-- +CREATE TABLE [prefix_participant_attribute] ( + [participant_id] varchar(50) NOT NULL, + [attribute_id] int(11) NOT NULL, + [value] varchar(50) NOT NULL, + PRIMARY KEY ([participant_id],[attribute_id]) +); +-- +-- Table structure for table participant attribute names +-- +CREATE TABLE [prefix_participant_attribute_names] ( + [attribute_id] int(11) NOT NULL AUTO_INCREMENT, + [attribute_type] varchar(4) NOT NULL, + [visible] char(5) NOT NULL, + PRIMARY KEY ([attribute_id],[attribute_type]) +); +-- +-- Table structure for table participant attribute names lang +-- +CREATE TABLE [prefix_participant_attribute_names_lang] ( + [id] int(11) NOT NULL AUTO_INCREMENT, + [attribute_id] int(11) NOT NULL, + [attribute_name] varchar(30) NOT NULL, + [lang] varchar(4) NOT NULL, + PRIMARY KEY ([attribute_id],[attribute_type]) +); +-- +-- Table structure for table participant attribute values +-- +CREATE TABLE [prefix_participant_attribute_values] ( + [attribute_id] int(11) NOT NULL, + [value_id] int(11) NOT NULL AUTO_INCREMENT, + [value] varchar(20) NOT NULL, + PRIMARY KEY ([attribute_id],[value_id]) +); +-- +-- Table structure for table participant shares +-- +CREATE TABLE [prefix_participant_shares] ( + [participant_id] varchar(50) NOT NULL, + [share_uid] int(11) NOT NULL, + [date_added] datetime, + [can_edit] text NOT NULL +); +-- +-- Table structure for table survey links +-- +CREATE TABLE [prefix_survey_links] ( + [participant_id] varchar(50) NOT NULL, + [token_id] int(11) NOT NULL, + [survey_id] int(11) NOT NULL, + [date_created] datetime +); -- -- Table structure for table templates -- @@ -447,11 +514,11 @@ create index [parent_qid_idx] on [prefix_questions] ([parent_qid]); -- -- Version Info -- -INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '147'); +INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '148'); INSERT INTO [prefix_settings_global] VALUES ('SessionName', '$sessionname'); -- -- Create admin user -- -INSERT INTO [prefix_users] ([users_name], [password], [full_name], [parent_id], [lang] ,[email], [create_survey], [create_user] ,[delete_user] ,[superadmin] ,[configurator] ,[manage_template] , [manage_label]) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1); +INSERT INTO [prefix_users] ([users_name], [password], [full_name], [parent_id], [lang] ,[email], [participant_panel], [create_survey], [create_user] ,[delete_user] ,[superadmin] ,[configurator] ,[manage_template] , [manage_label]) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1,1); diff --git a/installer/sql/create-mssqlnative.sql b/installer/sql/create-mssqlnative.sql index cc1b6c083d4..6a0f56857d2 100644 --- a/installer/sql/create-mssqlnative.sql +++ b/installer/sql/create-mssqlnative.sql @@ -392,6 +392,7 @@ CREATE TABLE [prefix_users] ( [email] VARCHAR(320) NOT NULL UNIQUE, [create_survey] TINYINT NOT NULL default '0', [create_user] TINYINT NOT NULL default '0', + [participant_panel] TINYINT NOT NULL default '0', [delete_user] TINYINT NOT NULL default '0', [superadmin] TINYINT NOT NULL default '0', [configurator] TINYINT NOT NULL default '0', @@ -415,6 +416,75 @@ CREATE TABLE [prefix_templates_rights] ( PRIMARY KEY ([uid],[folder]) ); +-- +-- Table structure for table participants +-- +CREATE TABLE [prefix_participants] ( + [participant_id] varchar(50) NOT NULL, + [firstname] varchar(40) NOT NULL, + [lastname] varchar(40) NOT NULL, + [email] varchar(80) NOT NULL, + [language] varchar(2) NOT NULL, + [blacklisted] varchar(80) NOT NULL, + [owner_uid] int(20) NOT NULL, + PRIMARY KEY ([participant_id]) + ); +-- +-- Table structure for table participant attribute +-- +CREATE TABLE [prefix_participant_attribute] ( + [participant_id] varchar(50) NOT NULL, + [attribute_id] int(11) NOT NULL, + [value] varchar(50) NOT NULL, + PRIMARY KEY ([participant_id],[attribute_id]) + ); +-- +-- Table structure for table participant attribute names +-- +CREATE TABLE [prefix_participant_attribute_names] ( + [attribute_id] int(11) NOT NULL AUTO_INCREMENT, + [attribute_type] varchar(30) NOT NULL, + [visible] char(5) NOT NULL, + PRIMARY KEY ([attribute_id],[attribute_type]) + ); +-- +-- Table structure for table participant attribute names lang +-- +CREATE TABLE [prefix_participant_attribute_names_lang] ( + [id] int(11) NOT NULL AUTO_INCREMENT, + [attribute_id] int(11) NOT NULL, + [attribute_name] varchar(30) NOT NULL, + [lang] varchar(4) NOT NULL, + PRIMARY KEY ([attribute_id],[lang]) + ); +-- +-- Table structure for table participant attribute values +-- +CREATE TABLE [prefix_participant_attribute_values] ( + [attribute_id] int(11) NOT NULL, + [value_id] int(11) NOT NULL AUTO_INCREMENT, + [value] varchar(20) NOT NULL, + PRIMARY KEY ([attribute_id],[value_id]) + ); +-- +-- Table structure for table participant shares +-- +CREATE TABLE [prefix_participant_shares] ( + [participant_id] varchar(50) NOT NULL, + [shared_uid] int(11) NOT NULL, + [date_added] datetime, + [can_edit] varchar(5) NOT NULL + ); +-- +-- Table structure for table survey links +-- +CREATE TABLE [prefix_survey_links] ( + [participant_id] varchar(50) NOT NULL, + [token_id] int(11) NOT NULL, + [survey_id] int(11) NOT NULL, + [date_created] datetime + ); + -- -- Table structure for table templates @@ -459,11 +529,11 @@ create index [parent_qid_idx] on [prefix_questions] ([parent_qid]); -- -- Version Info -- -INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '147'); +INSERT INTO [prefix_settings_global] VALUES ('DBVersion', '148'); INSERT INTO [prefix_settings_global] VALUES ('SessionName', '$sessionname'); -- -- Create admin user -- -INSERT INTO [prefix_users] ([users_name], [password], [full_name], [parent_id], [lang] ,[email], [create_survey], [create_user] ,[delete_user] ,[superadmin] ,[configurator] ,[manage_template] , [manage_label]) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1); +INSERT INTO [prefix_users] ([users_name], [password], [full_name], [parent_id], [lang] ,[email], [create_survey], [participant_panel], [create_user] ,[delete_user] ,[superadmin] ,[configurator] ,[manage_template] , [manage_label]) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1,1); diff --git a/installer/sql/create-mysql.sql b/installer/sql/create-mysql.sql index f279c13a6a1..96a99d16cbf 100644 --- a/installer/sql/create-mysql.sql +++ b/installer/sql/create-mysql.sql @@ -368,6 +368,7 @@ CREATE TABLE `prefix_users` ( `email` varchar(320), `create_survey` tinyint(1) NOT NULL default '0', `create_user` tinyint(1) NOT NULL default '0', + `participant_panel` tinyint(1) NOT NULL default '0', `delete_user` tinyint(1) NOT NULL default '0', `superadmin` tinyint(1) NOT NULL default '0', `configurator` tinyint(1) NOT NULL default '0', @@ -390,8 +391,75 @@ CREATE TABLE `prefix_templates_rights` ( `use` int(1) NOT NULL, PRIMARY KEY (`uid`,`folder`) ) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; - - +-- +-- Table structure for table participants +-- +CREATE TABLE `prefix_participants` ( + `participant_id` varchar(50) NOT NULL, + `firstname` varchar(40) NOT NULL, + `lastname` varchar(40) NOT NULL, + `email` varchar(80) NOT NULL, + `language` varchar(2) NOT NULL, + `blacklisted` varchar(1) NOT NULL, + `owner_uid` int(20) NOT NULL, + PRIMARY KEY (`participant_id`) +) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- +-- Table structure for table participant_attribute +-- +CREATE TABLE `prefix_participant_attribute` ( + `participant_id` varchar(50) NOT NULL, + `attribute_id` int(11) NOT NULL, + `value` varchar(50) NOT NULL, + PRIMARY KEY (`participant_id`,`attribute_id`) +) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- +-- Table structure for table participant_attribute_names_lang +-- +CREATE TABLE `prefix_participant_attribute_names_lang` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `attribute_id` int(11) NOT NULL, + `attribute_name` varchar(30) NOT NULL, + `lang` varchar(4) NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- +-- Table structure for table participant_attribute_names +-- +CREATE TABLE `prefix_participant_attribute_names` ( + `attribute_id` int(11) NOT NULL AUTO_INCREMENT, + `attribute_type` varchar(4) NOT NULL, + `visible` char(5) NOT NULL, + PRIMARY KEY (`attribute_id`) +) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- +-- Table structure for table participant_attribute_names_values +-- +CREATE TABLE `prefix_participant_attribute_values` ( + `attribute_id` int(11) NOT NULL, + `value_id` int(11) NOT NULL AUTO_INCREMENT, + `value` varchar(20) NOT NULL, + PRIMARY KEY (`value_id`,`attribute_id`) +) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- +-- Table structure for table participant_shares +-- +CREATE TABLE `prefix_participant_shares` ( + `participant_id` varchar(50) NOT NULL, + `share_uid` int(11) NOT NULL, + `date_added` datetime NOT NULL, + `can_edit` varchar(5) NOT NULL + ) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; +-- +-- Table structure for table survey_links +-- +CREATE TABLE `prefix_survey_links` ( + `participant_id` varchar(50) NOT NULL, + `token_id` int(11) NOT NULL, + `survey_id` int(11) NOT NULL, + `datecreated` datetime NOT NULL, + PRIMARY KEY (`participant_id`,`token_id`,`survey_id`) + ) ENGINE=$databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; -- -- Table structure for table templates -- @@ -434,12 +502,12 @@ create index `parent_qid_idx` on `prefix_questions` (`parent_qid`); -- -- Version Info -- -INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '147'); +INSERT INTO `prefix_settings_global` VALUES ('DBVersion', '148'); INSERT INTO `prefix_settings_global` VALUES ('SessionName', '$sessionname'); -- -- Create admin user -- -INSERT INTO `prefix_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang` ,`email`, `create_survey`,`create_user` ,`delete_user` ,`superadmin` ,`configurator` ,`manage_template` , `manage_label`) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1); +INSERT INTO `prefix_users` (`users_name`, `password`, `full_name`, `parent_id`, `lang` ,`email`, `create_survey`, `participant_panel`,`create_user` ,`delete_user` ,`superadmin` ,`configurator` ,`manage_template` , `manage_label`) VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail', 1,1,1,1,1,1,1,1); diff --git a/installer/sql/create-postgres.sql b/installer/sql/create-postgres.sql index 81f69efdedb..73259a3f528 100644 --- a/installer/sql/create-postgres.sql +++ b/installer/sql/create-postgres.sql @@ -394,6 +394,7 @@ CREATE TABLE prefix_users ( email character varying(320) NOT NULL, create_survey integer DEFAULT 0 NOT NULL, create_user integer DEFAULT 0 NOT NULL, + participant_panel integer DEFAULT 0 NOT NULL, delete_user integer DEFAULT 0 NOT NULL, superadmin integer DEFAULT 0 NOT NULL, configurator integer DEFAULT 0 NOT NULL, @@ -416,6 +417,76 @@ CREATE TABLE prefix_templates_rights ( "use" integer NOT NULL ); +-- +-- Table structure for table participants +-- +CREATE TABLE prefix_participants ( + "participant_id" VARCHAR( 50 ) NOT NULL, + "firstname" VARCHAR( 40 ) NOT NULL, + "lastname" VARCHAR( 40 ) NOT NULL, + "email" VARCHAR( 80 ) NOT NULL, + "language" VARCHAR( 2 ) NOT NULL, + "blacklisted" VARCHAR( 1 ) NOT NULL, + "owner_uid" integer NOT NULL, + PRIMARY KEY (participant_id) +); +-- +-- Table structure for table participant_attribute +-- +CREATE TABLE prefix_participant_attribute ( + "participant_id" VARCHAR( 50 ) NOT NULL, + "attribute_id" integer NOT NULL, + "value" integer NOT NULL, + PRIMARY KEY (participant_id,attribute_id) +); +-- +-- Table structure for table participant_attribute_names +-- +CREATE TABLE prefix_participant_attribute_names ( + "attribute_id" integer NOT NULL AUTO_INCREMENT, + "attribute_type" VARCHAR( 30 ) NOT NULL, + "visible" CHAR( 5 ) NOT NULL, + PRIMARY KEY (attribute_type,attribute_id) +); +-- +-- Table structure for table participant_attribute_lang +-- +CREATE TABLE prefix_participant_attribute_names_lang ( + "id" integer NOT NULL AUTO_INCREMENT, + "attribute_id" integer NOT NULL, + "attribute_name" VARCHAR( 30 ) NOT NULL, + "lang" CHAR( 5 ) NOT NULL, + PRIMARY KEY (lang,attribute_id) +); +-- +-- Table structure for table participant_attribute_values +-- +CREATE TABLE prefix_participant_attribute_values ( + "attribute_id" integer NOT NULL, + "value_id" integer NOT NULL AUTO_INCREMENT, + "value" VARCHAR( 20 ) NOT NULL, + PRIMARY KEY (attribute_id,value_id) +); +-- +-- Table structure for table participant_shares +-- +CREATE TABLE prefix_participant_shares ( + "participant_id" VARCHAR( 50 ) NOT NULL, + "shared_uid" integer NOT NULL, + "date_added" date NOT NULL, + "can_edit" VARCHAR( 5 ) NOT NULL +); +-- +-- Table structure for table participant_attribute_values +-- +CREATE TABLE prefix_survey_links ( + "participant_id" VARCHAR( 50 ) NOT NULL, + "token_id" integer NOT NULL, + "survey_id" integer NOT NULL, + "date_created" date NOT NULL, + PRIMARY KEY (participant_id,token_id,survey_id) +); + ALTER TABLE ONLY prefix_templates_rights ADD CONSTRAINT prefix_templates_rights_pkey PRIMARY KEY ("uid","folder"); @@ -459,7 +530,7 @@ create index parent_qid_idx on prefix_questions (parent_qid); -- -- Version Info -- -INSERT INTO prefix_settings_global VALUES ('DBVersion', '147'); +INSERT INTO prefix_settings_global VALUES ('DBVersion', '148'); INSERT INTO prefix_settings_global VALUES ('SessionName', '$sessionname'); @@ -469,6 +540,6 @@ INSERT INTO prefix_settings_global VALUES ('SessionName', '$sessionname'); INSERT INTO prefix_users( users_name, "password", full_name, parent_id, lang, email, - create_survey, create_user, delete_user, superadmin, configurator, + create_survey, create_user, participant_panel, delete_user, superadmin, configurator, manage_template, manage_label,htmleditormode) - VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail',1,1,1,1,1,1,1,'default'); + VALUES ('$defaultuser', '$defaultpass', '$siteadminname', 0, '$defaultlang', '$siteadminemail',1,1,1,1,1,1,1,1,'default'); diff --git a/scripts/admin/displayParticipant.js b/scripts/admin/displayParticipant.js index 73bd2d80093..8bbf2c34815 100644 --- a/scripts/admin/displayParticipant.js +++ b/scripts/admin/displayParticipant.js @@ -1,451 +1,464 @@ -var idexternal=parseInt(3); -function addcondition() -{id=2; - html = ""+optionstring+"\n\ - \n\\n\ - \n\ - "; - //$('#searchtable > tbody > tr').eq(id).after(html); - $('#searchtable > tbody > tr').eq(idexternal).after(html); - idexternal++; - $('#searchtable > tbody > tr').eq(idexternal).after(html2); - idexternal++; -} -$(document).ready(function() { -// Code for AJAX download -jQuery.download = function(url, data, method){ - //url and data options required - if( url && data ){ - //data can be string of parameters or array/object - data = typeof data == 'string' ? data : jQuery.param(data); - //split params into form inputs - var inputs = ''; - jQuery.each(data.split('&'), function(){ - var pair = this.split('='); - inputs+=''; - }); - //send request - jQuery('
'+inputs+'
') - .appendTo('body').submit().remove(); - }; -}; -// Code for AJAX download -var id=1; -$("#addbutton").click(function(){ -id=2; -html = "\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -\n\ -"+optionstring+"\n\\n\\n\\n\\n\\n\ -\n\ -"; -$('#searchtable tr:last').after(html); -}); -var searchconditions = {}; -var field; -$('#searchbutton').click(function(){ - -}); -var lastSel,lastSel2; -jQuery("#displayparticipants").jqGrid({ -align:"center", -url: jsonUrl, -editurl: editUrl, -datatype: "json", -mtype: "post", -colNames : jQuery.parseJSON(colNames), -colModel: jQuery.parseJSON(colModels), -height: "100%", -width: "100%", -rowNum: 50, -editable:true, -scrollOffset:0, -autowidth: true, -sortable : true, -sortname: 'firstname', -sortorder: 'acs', -viewrecords : true, -rowList: [25,50,100,250,500,1000,5000,10000], -multiselect: true, -loadonce:true, -ondblClickRow: function(id) - { - var can_edit = $('#displayparticipants').getCell(id, 'can_edit'); - if(can_edit == 'false') - { - var dialog_buttons={}; - dialog_buttons[okBtn]=function(){ - $( this ).dialog( "close" ); - }; - /* End of building array for button functions */ - $('#notauthorised').dialog({ - modal: true, - title: "Access Denied", - buttons: dialog_buttons - }); - } - else - { - { - if(id && id!==lastSel) - { - jQuery('#displayparticipants').saveRow(lastSel); - lastSel=id; - } - } - jQuery('#displayparticipants').editRow(id,true); - } - }, - pager: "#pager", - caption: "Participants", - subGrid: true, - subGridRowExpanded: function(subgrid_id,row_id) { - subgrid_table_id = subgrid_id+"_t"; - pager_id = "p_"+subgrid_table_id; - second_subgrid_table_id = subgrid_id+"_tt"; //new name for table selector –> tt - second_pager_id = "p_"+second_subgrid_table_id; - $("#"+subgrid_id).html("
"); - $("#"+subgrid_id).append("
"); - jQuery("#"+second_subgrid_table_id).jqGrid({ - datatype: "json", - url: surveylinkUrl+'/'+row_id, - height: "100%", - width: "100%", - colNames:['Survey Name','Survey ID','Token ID','Date Added'], - colModel:[{name:'surveyname',index:'surveyname', width:100,align:'center'}, - {name:'surveyid',index:'surveyid', width:90,align:'center'}, - {name:'tokenid',index:'tokenid', width:100,align:'center'}, - {name:'dateadded',index:'added', width:120,align:'center'}], - caption: "Participant's Survey Information", - gridComplete: function () { - - var recs = $("#"+second_subgrid_table_id).jqGrid('getGridParam','reccount'); - if (recs == 0 || recs == null) { - //$("#"+second_subgrid_table_id).setGridHeight(40); - $("#hide_"+second_subgrid_table_id).hide(); - //$("#NoRecordContact").show(); - } - } - }); - jQuery("#"+subgrid_table_id).jqGrid({ - url: getAttribute_json+'/'+row_id, - editurl:editAttributevalue, - datatype: "json", - mtype: "post", - pgbuttons:false, - recordtext:'', - pgtext:'', - caption: "Participant's Attribute Information", - editable:true, - colNames: ['Actions','Participant ID','Attribute Type','Attribute Name','Attribute Value', 'Attribute Active for participant','Attribute Possible Values'], - colModel: [ {name:'act',index:'act',width:55,align:'center',sortable:false,formatter:'actions',formatoptions : {keys:true,onEdit:function(id){ }}}, - {name:'participant_id',index:'participant_id', width:150, sorttype:"string",align:"center",editable:true,hidden:true}, - {name:'atttype',index:'atttype', width:150, sorttype:"string",align:"center",editable:true,hidden:true}, - {name:'attname',index:'attname', width:150, sorttype:"string",align:"center",editable:false}, - {name:'attvalue',index:'attvalue', width:150, sorttype:"string",align:"center",editable:true}, - {name:'attap',index:'attap', width:150, sorttype:"string",align:"center",hidden:true,editable:true},//attribute active for participan - {name:'attpvalues',index:'attpvalues', width:150, sorttype:"string",align:"center",editable:true,hidden:true}], - - rowNum:20, - pager: pager_id, - gridComplete: function () { - $('div.ui-inline-del').html(''); - $('div.ui-inline-edit').html(''); - }, - - ondblClickRow: function(id,subgrid_id){ - var parid = id.split('_'); - var participant_id = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'participant_id'); - var can_edit = $('#displayparticipants').getCell(participant_id,'can_edit'); - if(can_edit == 'false') - { - var dialog_buttons={}; - dialog_buttons[okBtn]=function(){ - $( this ).dialog( "close" ); - }; - /* End of building array for button functions */ - $('#notauthorised').dialog({ - modal: true, - title: "Access Denied", - buttons: dialog_buttons - }); - } - else - { - - var att_type = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'atttype'); - if(att_type=="DP") - { - $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{editoptions:{dataInit:function (elem) {$(elem).datepicker();}}}); - } - if(att_type=="DD") - { - var att_p_values = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attpvalues'); - $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{edittype:'select',editoptions:{value:":Select One;"+att_p_values}}); - } - if(att_type=="TB") - { - $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{edittype:'text'}); - $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{editoptions:''}); - } - var attap = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attap'); - - if(id && id!==lastSel2) - { - jQuery("#displayparticipants_"+parid[0]+"_t").saveRow(lastSel2); - lastSel2=id; - } - $.fn.fmatter.rowactions(id,'displayparticipants_'+parid[0]+'_t','edit',0); - jQuery("#displayparticipants_"+parid[0]+"_t").jqGrid('editRow',id,true); - jQuery("#displayparticipants_"+parid[0]+"_t").editRow(id,true); - } - }, - height: '100%'}); - } - -}); - -jQuery("#displayparticipants").jqGrid('navGrid','#pager',{add:true,del:true,edit:false,refresh: true,search: true},{},{width : 400},{},{multipleSearch:true, multipleGroup:true}); -$("#displayparticipants").navButtonAdd('#pager',{caption:"",title:"Export to CSV", buttonicon:'exporticon', onClickButton:function(){ - $.post(exporttocsvcount, { searchcondition: jQuery('#displayparticipants').jqGrid('getGridParam', 'url')}, - function(data) { - titlemsg = data; - - var dialog_buttons={}; - dialog_buttons[cancelBtn]=function(){ - $(this).dialog("close"); - }; - dialog_buttons[exportBtn]=function(){ - //$.load(exporttocsv+"/"+$('#attributes').val(),{ } ); - var url = jQuery('#displayparticipants').jqGrid('getGridParam', 'url'); - $.download(exporttocsv+"/"+$('#attributes').val(),'searchcondition='+url ); - $(this).dialog("close"); - }; - - /* End of building array for button functions */ - $('#exportcsv').dialog({ - modal: true, - title: titlemsg, - buttons: dialog_buttons, - width : 400, - height : 400, - open: function(event, ui) { - $('#attributes').multiselect({noneSelectedText: 'Select Attributes',autoOpen:true}).multiselectfilter(); - } - }); - }); -}}); - -$("#displayparticipants").navButtonAdd('#pager',{caption:"",title:"Full Search", buttonicon:'searchicon', onClickButton:function(){ - - var dialog_buttons={}; - dialog_buttons[searchBtn]=function(){ - searchconditions=""; - var dialog_buttons={}; - if($('#field_1').val() == '') - { - dialog_buttons[okBtn]=function(){ - $( this ).dialog( "close" );}; - /* End of building array for button functions */ - $('#fieldnotselected').dialog({ - modal: true, - title: error, - buttons: dialog_buttons - }); - } - else if($('#condition_1').val()=="") - { - dialog_buttons[okBtn]=function(){ - $( this ).dialog( "close" );}; - /* End of building array for button functions */ - $('#conditionnotselected').dialog({ - modal: true, - title: error, - buttons: dialog_buttons - }); - } - else - { - - if(id == 1) - { - searchconditions = searchconditions + $('#field_1').val()+"||"+$('#condition_1').val()+"||"+$('#conditiontext_1').val(); - jQuery("#displayparticipants").jqGrid('setGridParam',{url:jsonSearchUrl+'/'+searchconditions}).trigger("reloadGrid"); - } - else - { - searchconditions = $('#field_1').val()+"||"+$('#condition_1').val()+"||"+$('#conditiontext_1').val(); - for( i=2 ; i<=idexternal; i++) - { - - if($('#field_'+i).val()) - { - searchconditions = searchconditions + "||"+ $('#join_'+(i)).val()+"||"+$('#field_'+i).val()+"||"+$('#condition_'+i).val()+"||"+$('#conditiontext_'+i).val(); - } - } - jQuery("#displayparticipants").jqGrid('setGridParam',{url:jsonSearchUrl+'/'+searchconditions}).trigger("reloadGrid"); - } - $(this).dialog("close"); - } - }; - dialog_buttons[cancelBtn]=function(){ - $(this).dialog("close"); - }; - /* End of building array for button functions */ - $("#search").dialog({ - height: 300, - width: 750, - modal: true, - title : 'Full Search', - buttons: dialog_buttons - }); - -}}); - -$.extend(jQuery.jgrid.edit,{closeAfterAdd: true,reloadAfterSubmit: true,closeOnEspace:true}); - //script for sharing of participants - $("#sharingparticipants").dialog({ - title: spTitle, - modal: true, - autoOpen: false, - height: 200, - width: 400, - show: 'blind', - hide: 'blind' - }); - function shareParticipants(participant_id) { - var myGrid = $("#displayparticipants").jqGrid(); - var pid = myGrid .getGridParam('selarrrow'); - $("#shareform").load(shareUrl, { - participantid:pid, - shareuser:$("#shareuser").val(), - can_edit:$('#can_edit').attr('checked') - }, function(msg){ - $(this).dialog("close"); - alert(msg+"."+shareMsg); - $(location).attr('href',redUrl); - }); - } - //End of Script for sharing - function addtoSurvey(participant_id,survey_id,redirect) { - $("#addsurvey").load(postUrl,{ - participantid:participant_id},function(){ - $(location).attr('href',attMapUrl+'/'+survey_id+'/'+redirect); - });} - - $('#share').click(function(){ - var myGrid = $("#displayparticipants").jqGrid(); - var row = myGrid .getGridParam('selarrrow'); - if(row=="") { - /* build an array containing the various button functions */ - /* Needed because it's the only way to label a button with a variable */ - var dialog_buttons={}; - dialog_buttons[okBtn]=function(){ - $( this ).dialog( "close" ); - }; - /* End of building array for button functions */ - $('#norowselected').dialog({ - modal: true, - buttons: dialog_buttons - }); - } - else - { - /* build an array containing the various button functions */ - /* Needed because it's the only way to label a button with a variable */ - var dialog_buttons={}; - dialog_buttons[spAddBtn]=function(){ - var row = myGrid .getGridParam('selarrrow'); - shareParticipants(row);}; - dialog_buttons[cancelBtn]=function(){ - $(this).dialog("close"); - }; - /* End of building array for button functions */ - $("#shareform").dialog({ - height: 300, - width: 350, - modal: true, - buttons: dialog_buttons - }); - } - if (!($("#shareuser").length > 0)) { - $('#shareform').html(sfNoUser); - } - }); - - $('#addtosurvey').click(function() { - var myGrid = $("#displayparticipants").jqGrid(); - var rows = myGrid.getGridParam('selarrrow'); - if(rows=="") { - /* build an array containing the various button functions */ - /* Needed because it's the only way to label a button with a variable */ - var dialog_buttons={}; - dialog_buttons[okBtn]=function(){ - $( this ).dialog( "close" ); - }; - /* End of building array for button functions */ - $('#norowselected').dialog({ - modal: true, - buttons: dialog_buttons - }); - } - - else - { - var dialog_buttons={}; - dialog_buttons[mapButton]=function(){ - var survey_id=$('#survey_id').val(); - var redirect =""; - - if(survey_id=="") - { - - alert(selectSurvey); - } - else - { - if(jQuery('#redirect').is(":checked")) - { - redirect = "redirect"; - } - else - { - redirect = ""; - } - addtoSurvey(rows,survey_id,redirect); - } - }; - dialog_buttons[cancelBtn]=function(){ - $(this).dialog("close"); - }; - /* End of building array containing button functions */ - $("#addsurvey").dialog({ - height: 300, - width: 400, - title : addpartTitle, - modal: true, - buttons: dialog_buttons}); - } - if (!($("#survey_id").length > 0)) { - $('#addsurvey').html(addpartErrorMsg); -} -}); +var idexternal=parseInt(3); +function addcondition() +{id=2; + html = ""+optionstring+"\n\ + \n\\n\ + \n\ + "; + //$('#searchtable > tbody > tr').eq(id).after(html); + $('#searchtable > tbody > tr').eq(idexternal).after(html); + idexternal++; + $('#searchtable > tbody > tr').eq(idexternal).after(html2); + idexternal++; +} +$(document).ready(function() { +// Code for AJAX download +jQuery.download = function(url, data, method){ + //url and data options required + if( url && data ){ + //data can be string of parameters or array/object + data = typeof data == 'string' ? data : jQuery.param(data); + //split params into form inputs + var inputs = ''; + jQuery.each(data.split('&'), function(){ + var pair = this.split('='); + inputs+=''; + }); + //send request + jQuery('
'+inputs+'
') + .appendTo('body').submit().remove(); + }; +}; +// Code for AJAX download +var id=1; +$("#addbutton").click(function(){ +id=2; +html = "\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +\n\ +"+optionstring+"\n\\n\\n\\n\\n\\n\ +\n\ +"; +$('#searchtable tr:last').after(html); +}); +var searchconditions = {}; +var field; +$('#searchbutton').click(function(){ + +}); +var lastSel,lastSel2; +jQuery("#displayparticipants").jqGrid({ +align:"center", +url: jsonUrl, +editurl: editUrl, +datatype: "json", +mtype: "post", +colNames : jQuery.parseJSON(colNames), +colModel: jQuery.parseJSON(colModels), +height: "100%", +width: "100%", +rowNum: 50, +editable:true, +scrollOffset:0, +autowidth: true, +sortable : true, +sortname: 'firstname', +sortorder: 'acs', +viewrecords : true, +rowList: [25,50,100,250,500,1000,5000,10000], +multiselect: true, +loadonce:true, +ondblClickRow: function(id) + { + var can_edit = $('#displayparticipants').getCell(id, 'can_edit'); + if(can_edit == 'false') + { + var dialog_buttons={}; + dialog_buttons[okBtn]=function(){ + $( this ).dialog( "close" ); + }; + /* End of building array for button functions */ + $('#notauthorised').dialog({ + modal: true, + title: "Access Denied", + buttons: dialog_buttons + }); + } + else + { + { + if(id && id!==lastSel) + { + jQuery('#displayparticipants').saveRow(lastSel); + lastSel=id; + } + } + jQuery('#displayparticipants').editRow(id,true); + } + }, + pager: "#pager", + caption: "Participants", + subGrid: true, + subGridRowExpanded: function(subgrid_id,row_id) { + subgrid_table_id = subgrid_id+"_t"; + pager_id = "p_"+subgrid_table_id; + second_subgrid_table_id = subgrid_id+"_tt"; //new name for table selector –> tt + second_pager_id = "p_"+second_subgrid_table_id; + $("#"+subgrid_id).html("
"); + $("#"+subgrid_id).append("
"); + jQuery("#"+second_subgrid_table_id).jqGrid({ + datatype: "json", + url: surveylinkUrl+'/'+row_id, + height: "100%", + width: "100%", + colNames:['Survey Name','Survey ID','Token ID','Date Added'], + colModel:[{name:'surveyname',index:'surveyname', width:100,align:'center'}, + {name:'surveyid',index:'surveyid', width:90,align:'center'}, + {name:'tokenid',index:'tokenid', width:100,align:'center'}, + {name:'dateadded',index:'added', width:120,align:'center'}], + caption: "Participant's Survey Information", + gridComplete: function () { + + var recs = $("#"+second_subgrid_table_id).jqGrid('getGridParam','reccount'); + if (recs == 0 || recs == null) { + //$("#"+second_subgrid_table_id).setGridHeight(40); + $("#hide_"+second_subgrid_table_id).hide(); + //$("#NoRecordContact").show(); + } + } + }); + jQuery("#"+subgrid_table_id).jqGrid({ + url: getAttribute_json+'/'+row_id, + editurl:editAttributevalue, + datatype: "json", + mtype: "post", + pgbuttons:false, + recordtext:'', + pgtext:'', + caption: "Participant's Attribute Information", + editable:true, + colNames: ['Actions','Participant ID','Attribute Type','Attribute Name','Attribute Value', 'Attribute Active for participant','Attribute Possible Values'], + colModel: [ {name:'act',index:'act',width:55,align:'center',sortable:false,formatter:'actions',formatoptions : {keys:true,onEdit:function(id){ }}}, + {name:'participant_id',index:'participant_id', width:150, sorttype:"string",align:"center",editable:true,hidden:true}, + {name:'atttype',index:'atttype', width:150, sorttype:"string",align:"center",editable:true,hidden:true}, + {name:'attname',index:'attname', width:150, sorttype:"string",align:"center",editable:false}, + {name:'attvalue',index:'attvalue', width:150, sorttype:"string",align:"center",editable:true}, + {name:'attap',index:'attap', width:150, sorttype:"string",align:"center",hidden:true,editable:true},//attribute active for participan + {name:'attpvalues',index:'attpvalues', width:150, sorttype:"string",align:"center",editable:true,hidden:true}], + + rowNum:20, + pager: pager_id, + gridComplete: function () { + $('div.ui-inline-del').html(''); + $('div.ui-inline-edit').html(''); + }, + + ondblClickRow: function(id,subgrid_id){ + var parid = id.split('_'); + var participant_id = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'participant_id'); + var can_edit = $('#displayparticipants').getCell(participant_id,'can_edit'); + if(can_edit == 'false') + { + var dialog_buttons={}; + dialog_buttons[okBtn]=function(){ + $( this ).dialog( "close" ); + }; + /* End of building array for button functions */ + $('#notauthorised').dialog({ + modal: true, + title: "Access Denied", + buttons: dialog_buttons + }); + } + else + { + + var att_type = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'atttype'); + if(att_type=="DP") + { + $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{editoptions:{dataInit:function (elem) {$(elem).datepicker();}}}); + } + if(att_type=="DD") + { + var att_p_values = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attpvalues'); + $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{edittype:'select',editoptions:{value:":Select One;"+att_p_values}}); + } + if(att_type=="TB") + { + $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{edittype:'text'}); + $("#displayparticipants_"+parid[0]+"_t").setColProp('attvalue',{editoptions:''}); + } + var attap = $("#displayparticipants_"+parid[0]+"_t").getCell(id,'attap'); + + if(id && id!==lastSel2) + { + jQuery("#displayparticipants_"+parid[0]+"_t").saveRow(lastSel2); + lastSel2=id; + } + $.fn.fmatter.rowactions(id,'displayparticipants_'+parid[0]+'_t','edit',0); + jQuery("#displayparticipants_"+parid[0]+"_t").jqGrid('editRow',id,true); + jQuery("#displayparticipants_"+parid[0]+"_t").editRow(id,true); + } + }, + height: '100%'}); + } + +}); +jQuery("#displayparticipants").jqGrid('navGrid','#pager',{add:true,del:true,edit:false,refresh: true,search: true},{},{ width : 400},{msg:deleteMsg, width : 700, beforeSubmit : function(postdata, formid) { + if(!$('#selectable .ui-selected').attr('id')) + { + alert(nooptionselected); + message = "dummy"; + } + else + { + $.post(delparticipantUrl, { participant_id : postdata ,selectedoption : $('#selectable .ui-selected').attr('id')}, function(data) {}); + success = "dummy"; + message = "dummy"; + return[success,message]; + } + +} ,beforeShowForm:function(form) {$('#selectable').bind("mousedown", function (e) {e.metaKey = false;}).selectable({tolerance: 'fit'})}},{multipleSearch:true, multipleGroup:true}); +$("#displayparticipants").navButtonAdd('#pager',{caption:"",title:"Export to CSV", buttonicon:'exporticon', onClickButton:function(){ + $.post(exporttocsvcount, {searchcondition: jQuery('#displayparticipants').jqGrid('getGridParam', 'url')}, + function(data) { + titlemsg = data; + + var dialog_buttons={}; + dialog_buttons[cancelBtn]=function(){ + $(this).dialog("close"); + }; + dialog_buttons[exportBtn]=function(){ + //$.load(exporttocsv+"/"+$('#attributes').val(),{ } ); + var url = jQuery('#displayparticipants').jqGrid('getGridParam', 'url'); + $.download(exporttocsv+"/"+$('#attributes').val(),'searchcondition='+url ); + $(this).dialog("close"); + }; + + /* End of building array for button functions */ + $('#exportcsv').dialog({ + modal: true, + title: titlemsg, + buttons: dialog_buttons, + width : 400, + height : 400, + open: function(event, ui) { + $('#attributes').multiselect({noneSelectedText: 'Select Attributes',autoOpen:true}).multiselectfilter(); + } + }); + }); +}}); + +$("#displayparticipants").navButtonAdd('#pager',{caption:"",title:"Full Search", buttonicon:'searchicon', onClickButton:function(){ + + var dialog_buttons={}; + dialog_buttons[searchBtn]=function(){ + searchconditions=""; + var dialog_buttons={}; + if($('#field_1').val() == '') + { + dialog_buttons[okBtn]=function(){ + $( this ).dialog( "close" );}; + /* End of building array for button functions */ + $('#fieldnotselected').dialog({ + modal: true, + title: error, + buttons: dialog_buttons + }); + } + else if($('#condition_1').val()=="") + { + dialog_buttons[okBtn]=function(){ + $( this ).dialog( "close" );}; + /* End of building array for button functions */ + $('#conditionnotselected').dialog({ + modal: true, + title: error, + buttons: dialog_buttons + }); + } + else + { + + if(id == 1) + { + searchconditions = searchconditions + $('#field_1').val()+"||"+$('#condition_1').val()+"||"+$('#conditiontext_1').val(); + jQuery("#displayparticipants").jqGrid('setGridParam',{url:jsonSearchUrl+'/'+searchconditions}).trigger("reloadGrid"); + } + else + { + searchconditions = $('#field_1').val()+"||"+$('#condition_1').val()+"||"+$('#conditiontext_1').val(); + for( i=2 ; i<=idexternal; i++) + { + + if($('#field_'+i).val()) + { + searchconditions = searchconditions + "||"+ $('#join_'+(i)).val()+"||"+$('#field_'+i).val()+"||"+$('#condition_'+i).val()+"||"+$('#conditiontext_'+i).val(); + } + } + jQuery("#displayparticipants").jqGrid('setGridParam',{url:jsonSearchUrl+'/'+searchconditions}).trigger("reloadGrid"); + } + $(this).dialog("close"); + } + }; + dialog_buttons[cancelBtn]=function(){ + $(this).dialog("close"); + }; + /* End of building array for button functions */ + $("#search").dialog({ + height: 300, + width: 750, + modal: true, + title : 'Full Search', + buttons: dialog_buttons + }); + +}}); + +$.extend(jQuery.jgrid.edit,{closeAfterAdd: true,reloadAfterSubmit: true,closeOnEspace:true}); + //script for sharing of participants + $("#sharingparticipants").dialog({ + title: spTitle, + modal: true, + autoOpen: false, + height: 200, + width: 400, + show: 'blind', + hide: 'blind' + }); + function shareParticipants(participant_id) { + var myGrid = $("#displayparticipants").jqGrid(); + var pid = myGrid .getGridParam('selarrrow'); + $("#shareform").load(shareUrl, { + participantid:pid, + shareuser:$("#shareuser").val(), + can_edit:$('#can_edit').attr('checked') + }, function(msg){ + $(this).dialog("close"); + alert(msg+"."+shareMsg); + $(location).attr('href',redUrl); + }); + } + //End of Script for sharing + function addtoSurvey(participant_id,survey_id,redirect) { + $("#addsurvey").load(postUrl,{ + participantid:participant_id},function(){ + $(location).attr('href',attMapUrl+'/'+survey_id+'/'+redirect); + });} + + $('#share').click(function(){ + var myGrid = $("#displayparticipants").jqGrid(); + var row = myGrid .getGridParam('selarrrow'); + if(row=="") { + /* build an array containing the various button functions */ + /* Needed because it's the only way to label a button with a variable */ + var dialog_buttons={}; + dialog_buttons[okBtn]=function(){ + $( this ).dialog( "close" ); + }; + /* End of building array for button functions */ + $('#norowselected').dialog({ + modal: true, + buttons: dialog_buttons + }); + } + else + { + /* build an array containing the various button functions */ + /* Needed because it's the only way to label a button with a variable */ + var dialog_buttons={}; + dialog_buttons[spAddBtn]=function(){ + var row = myGrid .getGridParam('selarrrow'); + shareParticipants(row);}; + dialog_buttons[cancelBtn]=function(){ + $(this).dialog("close"); + }; + /* End of building array for button functions */ + $("#shareform").dialog({ + height: 300, + width: 350, + modal: true, + buttons: dialog_buttons + }); + } + if (!($("#shareuser").length > 0)) { + $('#shareform').html(sfNoUser); + } + }); + + $('#addtosurvey').click(function() { + var myGrid = $("#displayparticipants").jqGrid(); + var rows = myGrid.getGridParam('selarrrow'); + if(rows=="") { + /* build an array containing the various button functions */ + /* Needed because it's the only way to label a button with a variable */ + var dialog_buttons={}; + dialog_buttons[okBtn]=function(){ + $( this ).dialog( "close" ); + }; + /* End of building array for button functions */ + $('#norowselected').dialog({ + modal: true, + buttons: dialog_buttons + }); + } + + else + { + var dialog_buttons={}; + dialog_buttons[mapButton]=function(){ + var survey_id=$('#survey_id').val(); + var redirect =""; + + if(survey_id=="") + { + + alert(selectSurvey); + } + else + { + if(jQuery('#redirect').is(":checked")) + { + redirect = "redirect"; + } + else + { + redirect = ""; + } + addtoSurvey(rows,survey_id,redirect); + } + }; + dialog_buttons[cancelBtn]=function(){ + $(this).dialog("close"); + }; + /* End of building array containing button functions */ + $("#addsurvey").dialog({ + height: 300, + width: 400, + title : addpartTitle, + modal: true, + buttons: dialog_buttons}); + } + if (!($("#survey_id").length > 0)) { + $('#addsurvey').html(addpartErrorMsg); +} +}); }); \ No newline at end of file diff --git a/scripts/jquery/jquery.ui.selectable.min.js b/scripts/jquery/jquery.ui.selectable.min.js new file mode 100644 index 00000000000..6e64a9d440f --- /dev/null +++ b/scripts/jquery/jquery.ui.selectable.min.js @@ -0,0 +1,22 @@ +/* + * jQuery UI Selectable 1.8.15 + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Selectables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */ +(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"), +selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("
")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, +c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting", +c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d= +this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom