From 16de6acfb4895fb96cd8239fd0062e29a77d3868 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 9 Sep 2015 03:46:58 +0300 Subject: [PATCH] set default list of outcomes when creating new questionnaire --- admin/new.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/admin/new.php b/admin/new.php index f9ae671f..61952567 100644 --- a/admin/new.php +++ b/admin/new.php @@ -76,8 +76,25 @@ if (isset($_POST['import_file'])) $lime_rs_sid = bigintval($_POST['selectrs']); } - $sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid,info,self_complete,referral) - VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid,$info,$respsc,$referral)"; +//** get default coma-separated outcomes list and use it for new questionnaire as initial set + $sql = "SELECT o.outcome_id + FROM `outcome` as o + WHERE o.deflt = 1;"; + $def = $db->GetAll($sql); + + for ($i=0; $i < count($def); $i++){ + foreach($def[$i] as $key => $val){ + $do[] = $val; + } + } + + $do = implode($do,","); + //print $do . "
"; + +//** - end + + $sql = "INSERT INTO questionnaire (questionnaire_id,description,lime_sid,restrict_appointments_shifts,restrict_work_shifts,respondent_selection,rs_intro,rs_project_intro,rs_project_end,rs_callback,rs_answeringmachine,testing,lime_rs_sid,info,self_complete,referral,outcomes) + VALUES (NULL,$name,'$lime_sid','$ras','$rws','$rs',$rs_intro,$rs_project_intro,$rs_project_end,$rs_callback,$rs_answeringmachine,'$testing',$lime_rs_sid,$info,$respsc,$referral,'$do')"; $rs = $db->Execute($sql); @@ -96,12 +113,12 @@ if (isset($_POST['import_file'])) $db->Execute($sql); } - $cl = info; + $cl = "info"; $message = T_("Successfully inserted") . " " . T_("with ID") . "  $qid,

" . T_("linked to survey") . "  $lime_sid "; } else{ - $cl = danger; + $cl = "danger"; $message = T_("Error: Failed to insert questionnaire"); }