mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Added customised outcomes feature (thanks Alex)
This commit is contained in:
@@ -117,6 +117,7 @@ include ("../functions/functions.operator.php");
|
||||
<li><a href="?g=1&page=<?php echo LIME_URL ;?>admin/admin.php?action=newsurvey"><i class="fa fa-file-text-o lime fa-fw"></i><?php print T_("Create an instrument in Limesurvey") ;?></a></li>
|
||||
<li><a href="?g=1&page=new.php"><i class="fa fa-plus-circle fa-fw"></i><?php print T_("Create a new questionnaire") ;?></a></li>
|
||||
<li><a href="?g=1&page=questionnairelist.php"><i class="fa fa-list fa-fw"></i><?php print T_("Questionnaire management") ;?></a></li>
|
||||
<li><a href="?g=1&page=set_outcomes.php?qid=0"><i class="fa fa-list-ol fa-fw"></i><?php print T_("Set questionnaire outcomes") ;?></a></li>
|
||||
<li><a href="?g=1&page=<?php echo LIME_URL ;?>admin/admin.php"><i class="fa fa-lemon-o lime fa-fw"></i><?php print T_("Administer instruments with Limesurvey") ;?></a></li>
|
||||
<li><a href="?g=1&page=questionnaireprefill.php"><i class="fa fa-thumb-tack fa-fw"></i><?php print T_("Pre-fill questionnaire") ;?></a></li>
|
||||
</ul>
|
||||
@@ -180,8 +181,9 @@ include ("../functions/functions.operator.php");
|
||||
</li>
|
||||
<li class="has_sub"><a href="" class=""><i class="fa fa-lg fa-gear"></i><span><?php print T_("System settings") ;?></span></a>
|
||||
<ul style="<?php if ($g == 9) echo "display:block";?>">
|
||||
<li><a href="?g=9&page=set_outcomes.php?default"><i class="fa fa-list-ol fa-fw"></i><?php print T_("Set default outcomes") ;?></a></li>
|
||||
<li><a href="?g=9&page=timezonetemplate.php"><i class="fa fa-globe fa-fw"></i><?php print T_("Set default timezone list") ;?></a></li>
|
||||
<li><a href="?g=9&page=availabilitygroup.php"><i class="fa fa-clock-o fa-fw"></i><?php print T_("Manage Time slots") ;?></a></li>
|
||||
<li><a href="?g=9&page=availabilitygroup.php"><i class="fa fa-clock-o fa-fw"></i><?php print T_("Manage Time slots") ;?></a></li>
|
||||
<li><a href="?g=9&page=shifttemplate.php"><i class="fa fa-calendar fa-fw"></i><?php print T_("Set default shift times") ;?></a></li>
|
||||
<li><a href="?g=9&page=callrestrict.php"><i class="fa fa-clock-o fa-fw"></i><?php print T_("Set call restriction times") ;?></a></li>
|
||||
<li><a href="?g=9&page=centreinfo.php"><i class="fa fa-university fa-fw"></i><?php print T_("Set centre information") ;?></a></li>
|
||||
|
||||
@@ -81,8 +81,24 @@ 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.default = 1;";
|
||||
$def = $db->GetAll($sql);
|
||||
|
||||
for ($i=0; $i < count($def); $i++){
|
||||
foreach($def[$i] as $key => $val){
|
||||
$do[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$do = implode($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);
|
||||
|
||||
@@ -101,12 +117,12 @@ if (isset($_POST['import_file']))
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
$cl = info;
|
||||
$cl = "info";
|
||||
$message = T_("Successfully inserted") . " " . T_("with ID") . "  $qid, </h4><h4>" . T_("linked to survey") . "  $lime_sid ";
|
||||
|
||||
}
|
||||
else{
|
||||
$cl = danger;
|
||||
$cl = "danger";
|
||||
$message = T_("Error: Failed to insert questionnaire");
|
||||
}
|
||||
|
||||
|
||||
@@ -581,6 +581,7 @@ else
|
||||
CONCAT('<a href=\'outcomes.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Outcomes for questionnaire"). " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-bar-chart fa-2x\'></i></a>')
|
||||
END as outcomes,
|
||||
CONCAT('<a href=\'callhistory.php?questionnaire_id=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Call history"). " \n" . TQ_("questionnaire"). " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-phone fa-2x\'></i></a>') as calls,
|
||||
CONCAT('<a href=\'set_outcomes.php?qid=',questionnaire_id,'\' class=\'btn\' title=\'" . TQ_("Set outcomes"). " \n" . TQ_("questionnaire"). " ',questionnaire_id,'\' data-toggle=\'tooltip\'><i class=\'fa fa-list-ol fa-2x\'></i></a>') as setoutcomes,
|
||||
CASE WHEN enabled = 0 THEN
|
||||
CONCAT('<i class=\'btn fa fa-download fa-2x\' style=\'color:lightgrey;\'></i>')
|
||||
ELSE
|
||||
@@ -599,7 +600,7 @@ else
|
||||
FROM questionnaire";
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$columns = array("qid","description","status","enabledisable","outcomes","calls","casestatus","shifts","assample","dataout","modify","inlime","prefill","deletee");
|
||||
$columns = array("qid","description","status","enabledisable","outcomes","calls","casestatus","shifts","assample","dataout","modify","setoutcomes","inlime","prefill","deletee");
|
||||
xhtml_table($rs,$columns,false,"table-hover table-condensed ");
|
||||
|
||||
print "</div>";
|
||||
|
||||
274
admin/set_outcomes.php
Normal file
274
admin/set_outcomes.php
Normal file
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration file
|
||||
*/
|
||||
require(dirname(__FILE__).'/../config.inc.php');
|
||||
|
||||
/**
|
||||
* Database
|
||||
*/
|
||||
require(dirname(__FILE__).'/../db.inc.php');
|
||||
|
||||
/**
|
||||
* Authentication file
|
||||
*/
|
||||
include ("auth-admin.php");
|
||||
|
||||
/**
|
||||
* XHTML functions
|
||||
*/
|
||||
require(dirname(__FILE__).'/../functions/functions.xhtml.php');
|
||||
|
||||
|
||||
$css = array(
|
||||
"../include/bootstrap/css/bootstrap.min.css",
|
||||
"../include/bootstrap/css/bootstrap-theme.min.css",
|
||||
"../include/font-awesome/css/font-awesome.css",
|
||||
"../include/bootstrap-toggle/css/bootstrap-toggle.min.css",
|
||||
"../css/custom.css"
|
||||
);
|
||||
$js_head = array(
|
||||
"../include/jquery/jquery.min.js",
|
||||
"../include/bootstrap/js/bootstrap.min.js",
|
||||
"../include/bootstrap-toggle/js/bootstrap-toggle.min.js",
|
||||
);
|
||||
$js_foot = array(
|
||||
"../js/window.js",
|
||||
"../js/bootstrap-confirmation.js",
|
||||
"../js/custom.js"
|
||||
);
|
||||
|
||||
global $db;
|
||||
|
||||
|
||||
if (isset($_POST['default']) && isset($_POST['save'])){
|
||||
|
||||
$sql = "UPDATE `outcome` as o
|
||||
SET `default` = 0
|
||||
WHERE o.permanent != 1";
|
||||
$db->Execute($sql);
|
||||
|
||||
if(!empty($_POST['select']) ){
|
||||
foreach($_POST['select'] as $n => $val)
|
||||
{
|
||||
$sel[] = $val;
|
||||
}
|
||||
$sel=implode($sel,",");
|
||||
|
||||
$sql = "UPDATE `outcome` as o
|
||||
SET `default` = 1
|
||||
WHERE o.permanent != 1
|
||||
AND o.outcome_id IN ($sel)";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
if(!empty($_POST['delay']) && $_SESSION['user'] === "admin" ){
|
||||
|
||||
foreach($_POST['delay'] as $n => $val)
|
||||
{
|
||||
$sql = "UPDATE `outcome`SET default_delay_minutes = $val WHERE outcome_id = $n";
|
||||
$db->Execute($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$_GET['default'] = $_POST['default'];
|
||||
|
||||
unset($_POST['default']);
|
||||
unset($_POST['save']);
|
||||
}
|
||||
|
||||
if (isset($_POST['qid']) && isset($_POST['save'])){
|
||||
|
||||
//get id's for 'permanent' outcomes
|
||||
$sql = "SELECT o.outcome_id
|
||||
FROM `outcome` as o
|
||||
WHERE o.permanent = 1
|
||||
AND o.default = 1;";
|
||||
$def = $db->GetAll($sql);
|
||||
|
||||
for ($i=0; $i < count($def); $i++){
|
||||
foreach($def[$i] as $key => $val){
|
||||
$sel[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($_POST['select']) ){
|
||||
//add selected outcomes
|
||||
foreach($_POST['select'] as $n => $val){
|
||||
$sel[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$sel=implode($sel,",");
|
||||
|
||||
$qid = intval($_POST['qid']);
|
||||
$sql = "UPDATE questionnaire
|
||||
SET outcomes = '$sel'
|
||||
WHERE questionnaire_id = $qid";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$_GET['qid'] = $_POST['qid'];
|
||||
|
||||
unset($_POST['qid']);
|
||||
unset($_POST['save']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*select outcomes list*/
|
||||
|
||||
if (isset($_GET['default'])) { $title = T_("Set default outcomes"); }
|
||||
else if (isset($_GET['qid'])){ $title = T_("Set questionnaire outcomes"); $qid = intval($_GET['qid']); }
|
||||
else die();
|
||||
|
||||
xhtml_head($title,true,$css,$js_head);
|
||||
|
||||
/* for questionnire outcomes */
|
||||
if (isset($_GET['qid'])) {
|
||||
|
||||
if($qid == 0) $qid = false;
|
||||
|
||||
print "<h3 class='form-inline pull-left'>" . T_("Questionnaire") . ": </h3>";
|
||||
|
||||
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$qid' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
FROM questionnaire
|
||||
WHERE enabled = 1";
|
||||
display_chooser($db->GetAll($sql),"questionnaire","qid", true,false,true,true,false,true,"form-inline pull-left ");
|
||||
|
||||
|
||||
if ($qid != false)
|
||||
{
|
||||
$qd = $db->GetRow("SELECT outcomes, self_complete, referral FROM `questionnaire` WHERE questionnaire_id = $qid");
|
||||
|
||||
$qoutc = $qd['outcomes'];
|
||||
$sc = $qd['self_complete'];
|
||||
$ref = $qd['referral'];
|
||||
|
||||
if (empty($qoutc)) { // update q.outcomes with default list
|
||||
|
||||
$sql = "SELECT o.outcome_id
|
||||
FROM `outcome` as o
|
||||
WHERE o.default = 1;";
|
||||
$def = $db->GetAll($sql);
|
||||
|
||||
for ($i=0; $i < count($def); $i++){
|
||||
foreach($def[$i] as $key => $val){
|
||||
$do[] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$qoutc = implode($do,",");
|
||||
|
||||
$sql = "UPDATE questionnaire
|
||||
SET outcomes = '$qoutc'
|
||||
WHERE questionnaire_id = $qid";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
|
||||
$sql = "SELECT o.*, ot.description as type,
|
||||
CONCAT('<input type=\'checkbox\'',
|
||||
CASE WHEN ((o.outcome_id = 40 AND $sc = 1) OR (o.outcome_id = 41 AND $ref = 1)) THEN 'checked=\"checked\" data-onstyle=\"success\"' ELSE '' END ,'',
|
||||
CASE WHEN ((o.outcome_id = 40 AND $sc != 1) OR (o.outcome_id = 41 AND $ref != 1)) THEN 'disabled=\"disabled\"' ELSE '' END ,'',
|
||||
CASE WHEN o.outcome_id NOT IN (40,41) AND o.outcome_id IN ($qoutc) THEN 'checked=\"checked\"' ELSE '' END ,'',
|
||||
CASE WHEN o.outcome_id NOT IN (40,41) AND o.permanent = 1 THEN 'disabled=\"disabled\" data-onstyle=\"success\"' ELSE '' END ,'
|
||||
name=\"select[]\" value=\'',o.outcome_id,'\' data-toggle=\"toggle\" data-size=\"small\" data-style=\"center-block\" data-on=" . TQ_("Yes") . " data-off=" . TQ_("No") . " data-width=\"70\"/>') as `select`
|
||||
from `outcome` as o, `outcome_type` as ot
|
||||
WHERE o.outcome_type_id = ot.outcome_type_id
|
||||
ORDER BY `o`.`outcome_id` ASC";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$row = array("outcome_id","description","type","select");
|
||||
$hdr = array(T_("Outcome ID"),T_("Description"),T_("Outcome type"),T_("Select"));
|
||||
$hid = "qid";
|
||||
$value = "$qid";
|
||||
}
|
||||
}
|
||||
|
||||
/* for default outcomes */
|
||||
if (isset($_GET['default'])) {
|
||||
|
||||
$sql = "SELECT o.*, ot.description as type,
|
||||
CONCAT('<input type=\'number\' name=\"delay[', o.outcome_id ,']\" class=\'form-control text-right\' style=\'width:7em;\' max=50000 min=0 required value=\'', o.default_delay_minutes ,'\' />') as `delay`,
|
||||
CONCAT('<h4> <span class=\"label label-', CASE WHEN o.tryanother = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as tryanother,
|
||||
CONCAT('<h4> <span class=\"label label-', CASE WHEN o.tryagain = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as tryagain,
|
||||
CONCAT('<h4> <span class=\"label label-', CASE WHEN o.contacted = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as contacted,
|
||||
CONCAT('<h4> <span class=\"label label-', CASE WHEN o.eligible = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as eligible,
|
||||
CONCAT('<h4> <span class=\"label label-', CASE WHEN o.require_note = 1 THEN 'primary\">" . T_("Yes") . "' ELSE 'default\">" . T_("No") . "' END , '</span></h4>') as require_note,
|
||||
CONCAT('<input type=\'checkbox\' ', CASE WHEN o.default = 1 THEN 'checked=\"checked\"' ELSE '' END ,' ', CASE WHEN o.permanent = 1 THEN 'disabled=\"disabled\" data-onstyle=\"success\"' ELSE '' END ,' name=\"select[]\" value=\'',o.outcome_id,'\' data-toggle=\"toggle\" data-size=\"small\" data-style=\"center-block\" data-on=" . TQ_("Yes") . " data-off=" . TQ_("No") . " data-width=\"70\" />') as `select`
|
||||
from `outcome` as o, `outcome_type` as ot
|
||||
WHERE o.outcome_type_id = ot.outcome_type_id
|
||||
ORDER BY `o`.`outcome_id` ASC";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$row = array("outcome_id","description","select","type","delay","contacted","tryanother","tryagain","eligible","require_note");
|
||||
$hdr = array(T_("Outcome ID"),T_("Description"),T_("Default"),T_("Outcome type"),T_("Delay, min"),T_("Contacted"),T_("Try another"),T_("Try again"),T_("Eligible"),T_("Require note"));
|
||||
|
||||
/* allow delay edit only to superadmins (currenlty admin) */
|
||||
if ( $_SESSION['user'] != "admin"){ unset($row[4]); unset($hdr[4]); }
|
||||
|
||||
$hid = "default";
|
||||
$value = "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (isset($rs) && !empty($rs)){
|
||||
|
||||
translate_array($rs, array("description","type"));
|
||||
|
||||
for ($i = 0; $i < count($rs); $i++){
|
||||
foreach ($rs[$i] as $key => $val){
|
||||
if ($key == "type"){
|
||||
$rs[$i]['type'] = preg_replace("#\s*\(.+#m", '', $val); // cut description in bracets for 'outcome_type'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form enctype="multipart/form-data" action="?" method="post" class="form-horizontal col-lg-12" >
|
||||
|
||||
<?php xhtml_table($rs,$row,$hdr); ?>
|
||||
|
||||
<input type='hidden' name='<?php echo $hid; ?>' value='<?php echo $value;?>' /> </br>
|
||||
|
||||
<div class="row form-group">
|
||||
<div class="col-sm-4 ">
|
||||
<a href="questionnairelist.php" class="btn btn-default pull-right" ><i class="fa fa-list text-primary"></i> <?php echo T_("Cancel");?></a>
|
||||
</div>
|
||||
<div class="col-sm-4 ">
|
||||
<button type="submit" class="btn btn-primary pull-right btn-lg" name="save" ><i class="fa fa-check-square-o fa-lg"></i> <?php echo T_("Save selection"); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
/* else {
|
||||
|
||||
if (isset($_GET['default'])) { ?>
|
||||
<div class="well text-danger col-sm-4"><p><?php echo T_("ERROR: Check tables 'outcome' and 'outcome_type' in DB"); ?></p></div>
|
||||
<?php }
|
||||
|
||||
if (isset($_GET['qid']) ) { ?>
|
||||
<div class="well text-danger col-sm-4"><p><?php echo T_("ERROR: Check tables 'outcome' and 'questionnaire' in DB"); ?></p></div>
|
||||
<?php }
|
||||
|
||||
} */
|
||||
|
||||
xhtml_foot($js_foot);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user