2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

pages new look

modified input types, added field  restrictions  in   assignsample.php
This commit is contained in:
Alex
2015-03-23 12:35:57 +03:00
parent 4e565a8bbf
commit e3db2c8abf
4 changed files with 816 additions and 778 deletions

View File

@@ -1,267 +1,282 @@
<?php
/**
* Assign sample(s) to a questionnaire
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
*/
/**
* Configuration file
*/
include("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
$css = array(
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
"../include/font-awesome-4.3.0/css/font-awesome.css",
"../css/bootstrap-switch.min.css",
"../css/custom.css"
);
$js_head = array(
"../js/jquery-2.1.3.min.js",
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
"../js/bootstrap-switch.min.js",
"../js/window.js"
);
$js_foot = array(
"../js/bootstrap-confirmation.js",
"../js/custom.js"
);
global $db;
if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max']))
{
//need to add sample to questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$sid = bigintval($_GET['sample']);
$cm = bigintval($_GET['call_max']);
$cam = bigintval($_GET['call_attempt_max']);
$am = bigintval($_GET['answering_machine_messages']);
$selecttype = 0;
if (isset($_GET['selecttype'])) $selecttype = 1;
$an = 0;
if (isset($_GET['allownew'])) $an = 1;
$sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages,allow_new)
VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am', '$an')";
$db->Execute($sql);
}
if (isset($_POST['edit']))
{
//need to add sample to questionnaire
$questionnaire_id = bigintval($_POST['questionnaire_id']);
$sid = bigintval($_POST['sample_import_id']);
$cm = bigintval($_POST['call_max']);
$cam = bigintval($_POST['call_attempt_max']);
$am = bigintval($_POST['answering_machine_messages']);
$selecttype = 0;
if (isset($_POST['selecttype'])) $selecttype = 1;
$an = 0;
if (isset($_POST['allownew'])) $an = 1;
$sql = "UPDATE questionnaire_sample
SET call_max = '$cm',
call_attempt_max = '$cam',
random_select = '$selecttype',
answering_machine_messages = '$am',
allow_new = '$an'
WHERE questionnaire_id = '$questionnaire_id'
AND sample_import_id = '$sid'";
$db->Execute($sql);
}
if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
{
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$sid = bigintval($_GET['rsid']);
if (isset($_GET['edit']))
{
$subtitle = T_("Edit assignment parameters");
xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js")
$sql = "SELECT si.description as description,
qr.description as qdescription,
q.call_max,
q.call_attempt_max,
q.random_select,
q.answering_machine_messages,
q.allow_new
FROM questionnaire_sample as q, sample_import as si, questionnaire as qr
WHERE q.sample_import_id = si.sample_import_id
AND q.questionnaire_id = '$questionnaire_id'
AND si.sample_import_id = '$sid'
AND qr.questionnaire_id = q.questionnaire_id";
$qs = $db->GetRow($sql);
//print "<h1>" . T_("Edit sample details") . "<h1>";
print " <p><a href='?questionnaire_id=$questionnaire_id' class='btn btn-default '><i class='fa fa-chevron-left fa-lg text-primary'></i>&emsp;" . T_("Go back") . "</a></p>
<h2 class='col-sm-6'>" . T_("Questionnaire") . ": <span class='text-primary'>" . $qs['qdescription'] . "</span></h2>
<h2 class='col-sm-6'>" . T_("Sample") . ": <span class='text-primary'>" . $qs['description'] . "</span></h2>
<div class='panel-body form-group'>";
$allownew = $selected ="";
if ($qs['random_select'] == 1)
$selected = "checked=\"checked\"";
if ($qs['allow_new'] == 1)
$allownew = "checked=\"checked\"";
?>
<form action="?questionnaire_id=<?php echo $questionnaire_id;?>" method="post" class="form-horizontal">
<label for="call_max" class="control-label col-sm-4"><?php echo T_("Max calls");?></label><div class="col-sm-1"><input type="text" name="call_max" id="call_max" value="<?php echo $qs['call_max'];?>" class="form-control"/></div><label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="call_attempt_max" class="control-label col-sm-4"><?php echo T_("Max call attempts");?></label><div class="col-sm-1"><input type="text" name="call_attempt_max" id="call_attempt_max" value="<?php echo $qs['call_attempt_max'];?>" class="form-control"/></div><label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="answering_machine_messages" class="control-label col-sm-4"><?php echo T_("Number of answering machine messages to leave per case");?></label><div class="col-sm-1"> <input type="text" name="answering_machine_messages" id="answering_machine_messages" value="<?php echo $qs['answering_machine_messages'];?>" class="form-control"/></div><label class="control-label text-info"><?php echo "0 = " . T_("Never");?></label><br/><br/>
<label for="selecttype" class="control-label col-sm-4"><?php echo T_("Select from sample randomly?");?></label><div class="col-sm-1"><input type="checkbox" id = "selecttype" name="selecttype" <?php echo $selected;?> switch="yes" data-size="small" data-on-text="<?php echo T_("Yes");?>" data-off-text="<?php echo T_("No");?>"/></div><label class="control-label text-info"><?php echo T_("No") ." = ". T_("Sequentially");?></label><br/><br/>
<label for="allownew" class="control-label col-sm-4"><?php echo T_("Allow new numbers to be drawn?");?></label><div class="col-sm-1"><input type="checkbox" id = "allownew" name="allownew" <?php echo $allownew;?> class="col-sm-1" switch="yes" data-size="small" data-on-text="<?php echo T_("Yes");?>" data-off-text="<?php echo T_("No");?>"/></div><br/><br/>
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
<input type="hidden" name="sample_import_id" value="<?php print($sid); ?>"/>
<div class="col-sm-12 text-center"><button type="submit" name="edit" class="btn btn-primary"><i class="fa fa-floppy-o fa-lg"></i>&emsp;<?php echo T_("Save changes");?></button></div>
</form></div>
<script type="text/javascript">
$('[switch="yes"]').bootstrapSwitch();
</script>
<?php
xhtml_foot($js_foot);
die();
}
else
{
//need to remove rsid from questionnaire
$sql = "DELETE FROM questionnaire_sample
WHERE questionnaire_id = '$questionnaire_id'
AND sample_import_id = '$sid'";
$db->Execute($sql);
}
}
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
$subtitle = T_("List & Add Sample");
xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js")
print "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left'><i class='fa fa-chevron-left fa-lg text-primary'></i>&emsp;" . T_("Go back") . "</a>";
print "<h3 class='col-sm-4 text-right'>" . T_("Select a questionnaire") . ":</h3>";
display_questionnaire_chooser($questionnaire_id,false, "pull-left", "form-control");
if ($questionnaire_id != false)
{
print "<div class='clearfix '></div><div class='panel-body'>
<h3 class='text-primary'>". T_("Samples selected for this questionnaire") .":</h3>";
$sql = "SELECT si.description as description,
CASE WHEN q.call_max = 0 THEN '". TQ_("Unlimited") ."' ELSE q.call_max END as call_max,
CASE WHEN q.call_attempt_max = 0 THEN '". TQ_("Unlimited") . "' ELSE q.call_attempt_max END AS call_attempt_max,
CASE WHEN q.random_select = 0 THEN '". TQ_("Sequential") ."' ELSE '". TQ_("Random") . "' END as random_select,
CASE WHEN q.answering_machine_messages = 0 THEN '". TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages,
CASE WHEN q.allow_new = 0 THEN '". TQ_("No") ."' ELSE '".TQ_("Yes")."' END as allow_new,
CONCAT('<a href=\"?edit=edit&amp;questionnaire_id=$questionnaire_id&amp;rsid=', si.sample_import_id ,'\" data-toggle=\'tooltip\' title=\'". TQ_("Edit") ."\' class=\'btn center-block\'><i class=\'fa fa-pencil-square-o fa-lg\'></i></a>') as edit,
CONCAT('<a href=\'\' data-toggle=\'confirmation\' data-placement=\'top\' data-href=\"?questionnaire_id=$questionnaire_id&amp;rsid=', si.sample_import_id ,'\" class=\'btn center-block\'><i class=\'fa fa-chain-broken fa-lg\' data-toggle=\'tooltip\' title=\'". TQ_("Click to unassign") ."\'></i></a>') as unassign
FROM questionnaire_sample as q, sample_import as si
WHERE q.sample_import_id = si.sample_import_id
AND q.questionnaire_id = '$questionnaire_id'";
$qs = $db->GetAll($sql);
if (!empty($qs))
xhtml_table($qs,array("description","call_max","call_attempt_max","answering_machine_messages","random_select","allow_new","edit","unassign"),array(T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Allow new numbers to be drawn?"), T_("Edit"), T_("Unassign sample")));
else
print "<div class='alert text-danger'><h4>". T_("No samples selected for this questionnaire") ."</h4></div>";
$sql = "SELECT si.sample_import_id,si.description
FROM sample_import as si
LEFT JOIN questionnaire_sample as q ON (q.questionnaire_id = '$questionnaire_id' AND q.sample_import_id = si.sample_import_id)
WHERE q.questionnaire_id is NULL
AND si.enabled = 1";
$qs = $db->GetAll($sql);
print"</div>";
if (!empty($qs))
{
print "<div class='clearfix '></div>";
print "<div class='panel-body form-group'><h3 class='text-primary'>" . T_("Add a sample to this questionnaire:") . "</h3>";
?>
<form action="" method="get" class="form-horizontal">
<label for="sample" class="control-label col-sm-4"><?php echo T_("Select sample:");?></label><div class="col-sm-3"><select name="sample" id="sample" class="form-control " >
<?php foreach($qs as $q) { print "<option value=\"{$q['sample_import_id']}\">{$q['description']}</option>"; } ?> </select></div><br/><br/>
<label for="call_max" class="control-label col-sm-4"><?php echo T_("Max calls");?></label><div class="col-sm-1"><input type="text" name="call_max" id="call_max" value="0" class="form-control"/></div><label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="call_attempt_max" class="control-label col-sm-4"><?php echo T_("Max call attempts");?></label><div class="col-sm-1"><input type="text" name="call_attempt_max" id="call_attempt_max" value="0" class="form-control"/></div><label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="answering_machine_messages" class="control-label col-sm-4"><?php echo T_("Number of answering machine messages to leave per case");?></label><div class="col-sm-1"> <input type="text" name="answering_machine_messages" id="answering_machine_messages" value="0" class="form-control"/></div><label class="control-label text-info"><?php echo "0 = " . T_("Never");?></label><br/><br/>
<label for="selecttype" class="control-label col-sm-4"><?php echo T_("Select from sample randomly?");?></label><div class="col-sm-1"><input type="checkbox" id = "selecttype" name="selecttype" switch="yes" data-size="small" data-on-text="<?php echo T_("Yes");?>" data-off-text="<?php echo T_("No");?>"/></div><label class="control-label text-info"><?php echo T_("No") ." = ". T_("Sequentially");?></label><br/><br/>
<label for="allownew" class="control-label col-sm-4"><?php echo T_("Allow new numbers to be drawn?");?></label><div class="col-sm-1"><input type="checkbox" id = "allownew" name="allownew" checked="checked" class="col-sm-1" switch="yes" data-size="small" data-on-text="<?php echo T_("Yes");?>" data-off-text="<?php echo T_("No");?>"/></div><br/><br/>
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id);?>"/>
<div class="col-sm-12 text-center"><button type="submit" name="add_sample" class="btn btn-primary"><i class="fa fa-plus-circle fa-lg"></i>&emsp;<?php echo T_("Add sample");?></button></div>
</form></div>
<?php
}
}
xhtml_foot($js_foot);
?>
<script type="text/javascript">
$('[switch="yes"]').bootstrapSwitch();
$('[data-toggle="confirmation"]').confirmation()
<?php
/**
* Assign sample(s) to a questionnaire
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
*/
/**
* Configuration file
*/
include("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
$css = array(
"../include/bootstrap-3.3.2/css/bootstrap.min.css",
"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css",
"../include/font-awesome-4.3.0/css/font-awesome.css",
"../include/bootstrap-toggle/css/bootstrap-toggle.min.css",
"../css/custom.css"
);
$js_head = array(
"../js/jquery-2.1.3.min.js",
"../include/bootstrap-3.3.2/js/bootstrap.min.js",
"../include/bootstrap-toggle/js/bootstrap-toggle.min.js",
"../js/window.js"
);
$js_foot = array(
"../js/bootstrap-confirmation.js",
"../js/custom.js"
);
global $db;
if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max']))
{
//need to add sample to questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$sid = bigintval($_GET['sample']);
$cm = bigintval($_GET['call_max']);
$cam = bigintval($_GET['call_attempt_max']);
$am = bigintval($_GET['answering_machine_messages']);
$selecttype = 0;
if (isset($_GET['selecttype'])) $selecttype = 1;
$an = 0;
if (isset($_GET['allownew'])) $an = 1;
$sql = "INSERT INTO questionnaire_sample(questionnaire_id,sample_import_id,call_max,call_attempt_max,random_select,answering_machine_messages,allow_new)
VALUES('$questionnaire_id','$sid','$cm','$cam','$selecttype','$am', '$an')";
$db->Execute($sql);
}
if (isset($_POST['edit']))
{
//need to add sample to questionnaire
$questionnaire_id = bigintval($_POST['questionnaire_id']);
$sid = bigintval($_POST['sample_import_id']);
$cm = bigintval($_POST['call_max']);
$cam = bigintval($_POST['call_attempt_max']);
$am = bigintval($_POST['answering_machine_messages']);
$selecttype = 0;
if (isset($_POST['selecttype'])) $selecttype = 1;
$an = 0;
if (isset($_POST['allownew'])) $an = 1;
$sql = "UPDATE questionnaire_sample
SET call_max = '$cm',
call_attempt_max = '$cam',
random_select = '$selecttype',
answering_machine_messages = '$am',
allow_new = '$an'
WHERE questionnaire_id = '$questionnaire_id'
AND sample_import_id = '$sid'";
$db->Execute($sql);
}
if (isset($_GET['questionnaire_id']) && isset($_GET['rsid']))
{
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$sid = bigintval($_GET['rsid']);
if (isset($_GET['edit']))
{
$subtitle = T_("Edit assignment parameters");
xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js")
$sql = "SELECT si.description as description,
qr.description as qdescription,
q.call_max,
q.call_attempt_max,
q.random_select,
q.answering_machine_messages,
q.allow_new
FROM questionnaire_sample as q, sample_import as si, questionnaire as qr
WHERE q.sample_import_id = si.sample_import_id
AND q.questionnaire_id = '$questionnaire_id'
AND si.sample_import_id = '$sid'
AND qr.questionnaire_id = q.questionnaire_id";
$qs = $db->GetRow($sql);
//print "<h1>" . T_("Edit sample details") . "<h1>";
print " <p><a href='?questionnaire_id=$questionnaire_id' class='btn btn-default '><i class='fa fa-chevron-left fa-lg text-primary'></i>&emsp;" . T_("Go back") . "</a></p>
<h2 class='col-sm-6'>" . T_("Questionnaire") . ": <span class='text-primary'>" . $qs['qdescription'] . "</span></h2>
<h2 class='col-sm-6'>" . T_("Sample") . ": <span class='text-primary'>" . $qs['description'] . "</span></h2>
<div class='panel-body form-group'>";
$allownew = $selected ="";
if ($qs['random_select'] == 1)
$selected = "checked=\"checked\"";
if ($qs['allow_new'] == 1)
$allownew = "checked=\"checked\"";
?>
<form action="?questionnaire_id=<?php echo $questionnaire_id;?>" method="post" class="form-horizontal">
<label for="call_max" class="control-label col-sm-4"><?php echo T_("Max calls");?></label>
<div class="col-sm-1"><input type="number" min="0" max="20" style="width:6em;" name="call_max" id="call_max" value="<?php echo $qs['call_max'];?>" class="form-control"/></div>
<label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="call_attempt_max" class="control-label col-sm-4"><?php echo T_("Max call attempts");?></label>
<div class="col-sm-1"><input type="number" min="0" max="20" style="width:6em;" name="call_attempt_max" id="call_attempt_max" value="<?php echo $qs['call_attempt_max'];?>" class="form-control"/></div>
<label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="answering_machine_messages" class="control-label col-sm-4"><?php echo T_("Number of answering machine messages to leave per case");?></label>
<div class="col-sm-1"> <input type="number" min="0" max="20" style="width:6em;" name="answering_machine_messages" id="answering_machine_messages" value="<?php echo $qs['answering_machine_messages'];?>" class="form-control"/></div>
<label class="control-label text-info"><?php echo "0 = " . T_("Never");?></label><br/><br/>
<label for="selecttype" class="control-label col-sm-4"><?php echo T_("Select from sample randomly?");?></label>
<div class="col-sm-1"><input type="checkbox" id = "selecttype" name="selecttype" <?php echo $selected;?> data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div>
<label class="control-label text-info"><?php echo T_("No") ." = ". T_("Sequentially");?></label><br/><br/>
<label for="allownew" class="control-label col-sm-4"><?php echo T_("Allow new numbers to be drawn?");?></label>
<div class="col-sm-1"><input type="checkbox" id = "allownew" name="allownew" <?php echo $allownew;?> class="col-sm-1" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div><br/><br/>
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
<input type="hidden" name="sample_import_id" value="<?php print($sid); ?>"/>
<div class="col-sm-12 text-center"><button type="submit" name="edit" class="btn btn-primary"><i class="fa fa-floppy-o fa-lg"></i>&emsp;<?php echo T_("Save changes");?></button></div>
</form></div>
<?php
xhtml_foot($js_foot);
die();
}
else
{
//need to remove rsid from questionnaire
$sql = "DELETE FROM questionnaire_sample
WHERE questionnaire_id = '$questionnaire_id'
AND sample_import_id = '$sid'";
$db->Execute($sql);
}
}
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
$subtitle = T_("List & Add Sample");
xhtml_head(T_("Assign samples to questionnaire: "),true,$css,$js_head,false,false,false,$subtitle);//array("../css/table.css"),array("../js/window.js")
print "<a href='' onclick='history.back();return false;' class='btn btn-default pull-left'><i class='fa fa-chevron-left fa-lg text-primary'></i>&emsp;" . T_("Go back") . "</a>";
print "<h3 class='col-sm-4 text-right'>" . T_("Select a questionnaire") . ":</h3>";
display_questionnaire_chooser($questionnaire_id,false, "pull-left", "form-control");
if ($questionnaire_id != false)
{
print "<div class='clearfix '></div><div class='panel-body'>
<h3 class='text-primary'>". T_("Samples selected for this questionnaire") .":</h3>";
$sql = "SELECT si.description as description,
CASE WHEN q.call_max = 0 THEN '". TQ_("Unlimited") ."' ELSE q.call_max END as call_max,
CASE WHEN q.call_attempt_max = 0 THEN '". TQ_("Unlimited") . "' ELSE q.call_attempt_max END AS call_attempt_max,
CASE WHEN q.random_select = 0 THEN '". TQ_("Sequential") ."' ELSE '". TQ_("Random") . "' END as random_select,
CASE WHEN q.answering_machine_messages = 0 THEN '". TQ_("Never") . "' ELSE q.answering_machine_messages END as answering_machine_messages,
CASE WHEN q.allow_new = 0 THEN '". TQ_("No") ."' ELSE '".TQ_("Yes")."' END as allow_new,
CONCAT('<a href=\"?edit=edit&amp;questionnaire_id=$questionnaire_id&amp;rsid=', si.sample_import_id ,'\" data-toggle=\'tooltip\' title=\'". TQ_("Edit") ."\' class=\'btn center-block\'><i class=\'fa fa-pencil-square-o fa-lg\'></i></a>') as edit,
CONCAT('<a href=\'\' data-toggle=\'confirmation\' data-placement=\'top\' data-href=\"?questionnaire_id=$questionnaire_id&amp;rsid=', si.sample_import_id ,'\" class=\'btn center-block\'><i class=\'fa fa-chain-broken fa-lg\' data-toggle=\'tooltip\' title=\'". TQ_("Click to unassign") ."\'></i></a>') as unassign
FROM questionnaire_sample as q, sample_import as si
WHERE q.sample_import_id = si.sample_import_id
AND q.questionnaire_id = '$questionnaire_id'";
$qs = $db->GetAll($sql);
if (!empty($qs))
xhtml_table($qs,array("description","call_max","call_attempt_max","answering_machine_messages","random_select","allow_new","edit","unassign"),array(T_("Sample"), T_("Max calls"), T_("Max call attempts"), T_("Answering machine messages"), T_("Selection type"), T_("Allow new numbers to be drawn?"), T_("Edit"), T_("Unassign sample")));
else
print "<div class='alert text-danger'><h4>". T_("No samples selected for this questionnaire") ."</h4></div>";
$sql = "SELECT si.sample_import_id,si.description
FROM sample_import as si
LEFT JOIN questionnaire_sample as q ON (q.questionnaire_id = '$questionnaire_id' AND q.sample_import_id = si.sample_import_id)
WHERE q.questionnaire_id is NULL
AND si.enabled = 1";
$qs = $db->GetAll($sql);
print"</div>";
if (!empty($qs))
{
print "<div class='clearfix '></div>";
print "<div class='panel-body form-group'><h3 class='text-primary'>" . T_("Add a sample to this questionnaire:") . "</h3>";
?>
<form action="" method="get" class="form-horizontal">
<label for="sample" class="control-label col-sm-4"><?php echo T_("Select sample:");?></label>
<div class="col-sm-3"><select name="sample" id="sample" class="form-control " >
<?php foreach($qs as $q) { print "<option value=\"{$q['sample_import_id']}\">{$q['description']}</option>"; } ?> </select></div><br/><br/>
<label for="call_max" class="control-label col-sm-4"><?php echo T_("Max calls");?></label>
<div class="col-sm-1"><input type="number" min="0" max="20" style="width:6em;" name="call_max" id="call_max" value="0" class="form-control"/></div>
<label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="call_attempt_max" class="control-label col-sm-4"><?php echo T_("Max call attempts");?></label>
<div class="col-sm-1"><input type="number" min="0" max="20" style="width:6em;" name="call_attempt_max" id="call_attempt_max" value="0" class="form-control"/></div>
<label class="control-label text-info"><?php echo "0 = " . T_("Unlimited");?></label><br/><br/>
<label for="answering_machine_messages" class="control-label col-sm-4"><?php echo T_("Number of answering machine messages to leave per case");?></label>
<div class="col-sm-1"><input type="number" min="0" max="20" style="width:6em;" name="answering_machine_messages" id="answering_machine_messages" value="0" class="form-control"/></div>
<label class="control-label text-info"><?php echo "0 = " . T_("Never");?></label><br/><br/>
<label for="selecttype" class="control-label col-sm-4"><?php echo T_("Select from sample randomly?");?></label>
<div class="col-sm-1"><input type="checkbox" id = "selecttype" name="selecttype" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div>
<label class="control-label text-info"><?php echo T_("No") ." = ". T_("Sequentially");?></label><br/><br/>
<label for="allownew" class="control-label col-sm-4"><?php echo T_("Allow new numbers to be drawn?");?></label>
<div class="col-sm-1"><input type="checkbox" id = "allownew" name="allownew" checked="checked" class="col-sm-1" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div><br/><br/>
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id);?>"/>
<div class="col-sm-12 text-center"><button type="submit" name="add_sample" class="btn btn-primary"><i class="fa fa-plus-circle fa-lg"></i>&emsp;<?php echo T_("Add sample");?></button></div>
</form></div>
<?php
}
}
xhtml_foot($js_foot);
?>
<script type="text/javascript">
$('[data-toggle="confirmation"]').confirmation()
</script>

View File

@@ -1,99 +1,121 @@
<?php
/**
* Display a list of cases for a questionnaire based on the current outcome
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2012
* @package queXS
* @subpackage user
* @link http://www.acspri.org.au/software queXS was writen for ACSPRI
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Operator functions
*/
include("../functions/functions.operator.php");
xhtml_head(T_("Cases by outcome"),true,array("../css/table.css"));
//List the cases by outcome
$operator_id = get_operator_id();
if ($operator_id)
{
//get the outcome and the questionnaire
$outcome_id = intval($_GET['outcome_id']);
$questionnaire_id = intval($_GET['questionnaire_id']);
$sql = "SELECT o.description, q.description as qd
FROM `outcome` as o, questionnaire as q
WHERE o.outcome_id = '$outcome_id'
AND q.questionnaire_id = '$questionnaire_id'";
$rs = $db->GetRow($sql);
if (!empty($rs))
{
print "<h1>" . T_("Project") . ": {$rs['qd']}</h1>";
print "<h2>". T_("Current outcome:") ." " . T_($rs['description']) . "</h2>";
$sql = "SELECT CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id
FROM `case` as c
WHERE c.questionnaire_id = '$questionnaire_id'
AND c.current_outcome_id = '$outcome_id'
LIMIT 500";
$rs = $db->GetAll($sql);
if (empty($rs))
print "<p>" . T_("No cases with this outcome") . "</p>";
else
{
xhtml_table($rs,array("case_id"),array(T_("Case ID")));
}
}
else
print "<p>" . T_("Error with input") . "</p>";
}
else
print "<p>" . T_("No operator") . "</p>";
xhtml_foot();
?>
<?php
/**
* Display a list of cases for a questionnaire based on the current outcome
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2012
* @package queXS
* @subpackage user
* @link http://www.acspri.org.au/software queXS was writen for ACSPRI
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include ("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Operator functions
*/
include("../functions/functions.operator.php");
xhtml_head(T_("Cases by outcome"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"));
print "<div class='col-sm-3'><a onclick='history.back();return false;' href='' class='btn btn-default'>&emsp;" . T_("Go back") . "&emsp;</a></div>";
//List the cases by outcome
$operator_id = get_operator_id();
if ($operator_id)
{
//get the outcome and the questionnaire
$outcome_id = intval($_GET['outcome_id']);
$questionnaire_id = intval($_GET['questionnaire_id']);
$sql = "SELECT o.description, q.description as qd
FROM `outcome` as o, questionnaire as q
WHERE o.outcome_id = '$outcome_id'
AND q.questionnaire_id = '$questionnaire_id'";
$rs = $db->GetRow($sql);
if (!empty($rs)){
print "<h2 class=' '>" . T_("Project") . ":&emsp;<span class='text-primary'>{$rs['qd']}</span></h2>";
if($sample_import_id=intval($_GET['sample_import_id'])){
$sql = "SELECT si.description as sd
FROM `sample_import` as si
WHERE si.sample_import_id = '$sample_import_id' ;";
$sd = $db->GetRow($sql);
print "<h3>". T_("Sample:") ."&emsp;<span class='text-primary'>" . T_($sd['sd']) . "</span></h3>";
$sid = "AND s.import_id= '$sample_import_id'";
}
else{$sid = " ";};
if($oper_id= intval($_GET['oper_id'])){
$sql = "SELECT CONCAT(op.firstname, op.lastname) as opname
FROM `operator` as op
WHERE op.operator_id = '$oper_id' ;";
$on = $db->GetRow($sql);
print "<h3>". T_("Operator") ." : " . T_($on['opname']) . "</h3> oper_id = $oper_id ";
$opn = "AND c.current_operator_id= '$oper_id'";
}
else{$opn = " ";};
print "<h3 class=' '>". T_("Current outcome:") ."&emsp;<span class='text-primary'>" . T_($rs['description']) . "</span></h3>";
$sql = "SELECT CONCAT('<a href=\'supervisor.php?case_id=', c.case_id, '\'>', c.case_id, '</a>') as case_id
FROM `case` as c
LEFT JOIN `sample` as s ON ( s.sample_id = c.sample_id )
WHERE c.questionnaire_id = '$questionnaire_id'
AND c.current_outcome_id = '$outcome_id'
$sid
$opn
LIMIT 500";
$rs = $db->GetAll($sql);
print "<div class='panel-body col-sm-4' style='max-height:750px; overflow:auto;'>";
if (empty($rs))
print "<p>" . T_("No cases with this outcome") . "</p>";
else
{
xhtml_table($rs,array("case_id"),array(T_("Case ID")));
}
}
else
print "<p>" . T_("Error with input") . "</p>";
}
else
print "<p>" . T_("No operator") . "</p>";
print "</div>";
xhtml_foot();
?>

View File

@@ -1,198 +1,198 @@
<?php
/**
* Select and set questions to pre fill in the questionnaire
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
*/
/**
* Configuration file
*/
include("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']))
{
//need to add prefill to questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$value = $db->quote($_GET['value']);
$svar = $db->quote($_GET['svar']);
$sgqa = $db->quote($_GET['sgqa']);
if (!empty($_GET['svar']) && empty($_GET['value']))
$value = $svar;
$sql = "INSERT INTO questionnaire_prefill(questionnaire_id,lime_sgqa,value)
VALUES('$questionnaire_id',$sgqa,$value)";
$db->Execute($sql);
}
if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id']))
{
//need to remove prefill from questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$questionnaire_prefill_id = bigintval($_GET['questionnaire_prefill_id']);
$sql = "DELETE FROM questionnaire_prefill
WHERE questionnaire_prefill_id = '$questionnaire_prefill_id'";
$db->Execute($sql);
}
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,false,array("../js/window.js"));
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM questionnaire
WHERE enabled = 1";
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");
if ($questionnaire_id != false)
{
print "<h1>" . T_("Current pre fills (click to delete)") . "</h1>";
$sql = "SELECT questionnaire_prefill_id,lime_sgqa,value
FROM questionnaire_prefill
WHERE questionnaire_id = '$questionnaire_id'";
$r = $db->GetAll($sql);
if (empty($r))
{
print "<p>" . T_("Currently no pre fills") . "</p>";
}
else
{
foreach($r as $v)
{
print "<div><a href='?questionnaire_id=$questionnaire_id&amp;questionnaire_prefill_id={$v['questionnaire_prefill_id']}'>{$v['lime_sgqa']}: {$v['value']}</a></div>";
}
}
print "<h1>" . T_("Select a question to pre fill") . "</h1>";
$sql = "SELECT lime_sid
FROM questionnaire
WHERE questionnaire_id = '$questionnaire_id'";
$r = $db->GetRow($sql);
$lime_sid = $r['lime_sid'];
$sgqa = false;
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
$sql = "SELECT CONCAT( q.sid, 'X', q.gid, 'X', q.qid) AS value,
CASE WHEN qo.question IS NULL THEN q.question ELSE CONCAT(qo.question,' : ',q.question) END as description,
CASE WHEN CONCAT(q.sid, 'X', q.gid, 'X', q.qid) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM `" . LIME_PREFIX . "questions` AS q
LEFT JOIN `" . LIME_PREFIX . "questions` as qo ON (qo.qid = q.parent_qid)
WHERE q.sid = '$lime_sid'
ORDER BY CASE WHEN qo.question_order IS NULL THEN q.question_order ELSE qo.question_order + (q.question_order / 1000) END ASC";
$rs = $db->GetAll($sql);
for ($i=0; $i<count($rs); $i++)
{
$rs[$i]['description'] = substr(strip_tags($rs[$i]['description']),0,100);
}
display_chooser($rs,"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id");
if ($sgqa != false)
{
print "<h1>" . T_("Enter a value to pre fill this question with:") . "</h1>";
print "<p>";
print T_("Possible uses:");
print "</p><ul>";
print "<li>" . T_("{Respondent:firstName} First name of the respondent") . "</li>";
print "<li>" . T_("{Respondent:lastName} Last name of the respondent") . "</li>";
print "<li>" . T_("{Sample:var} A record from the sample where the column name is 'var'") . "</li>";
$sql = "SELECT sv.var as description, CONCAT('{Sample:', sv.var, '}') as value
FROM `sample` AS s, sample_var AS sv, questionnaire_sample as qs
WHERE qs.questionnaire_id = '$questionnaire_id'
AND s.import_id = qs.sample_import_id
AND s.sample_id = sv.sample_id
GROUP BY sv.var";
print "</ul>";
?>
<form action="" method="get">
<p>
<label for="value"><?php echo T_("The value to pre fill"); ?> </label><input type="text" name="value" id="value"/> <br/>
<label for="svar"><?php echo T_("or: Select pre fill from sample list"); ?> </label>
<?php //display a list of possible sample variables for this questionnaire
display_chooser($db->GetAll($sql),"svar","svar",true,false,false,false,false);
?> <br/>
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
<input type="hidden" name="sgqa" value="<?php print($sgqa); ?>"/>
<input type="submit" name="add_prefill" value="<?php print(T_("Add pre fill")); ?>"/></p>
</form>
<?php
}
}
xhtml_foot();
?>
<?php
/**
* Select and set questions to pre fill in the questionnaire
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@deakin.edu.au>
* @copyright Deakin University 2007,2008
* @package queXS
* @subpackage admin
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*
*/
/**
* Configuration file
*/
include("../config.inc.php");
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
global $db;
if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']))
{
//need to add prefill to questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$value = $db->quote($_GET['value']);
$svar = $db->quote($_GET['svar']);
$sgqa = $db->quote($_GET['sgqa']);
if (!empty($_GET['svar']) && empty($_GET['value']))
$value = $svar;
$sql = "INSERT INTO questionnaire_prefill(questionnaire_id,lime_sgqa,value)
VALUES('$questionnaire_id',$sgqa,$value)";
$db->Execute($sql);
}
if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_prefill_id']))
{
//need to remove prefill from questionnaire
$questionnaire_id = bigintval($_GET['questionnaire_id']);
$questionnaire_prefill_id = bigintval($_GET['questionnaire_prefill_id']);
$sql = "DELETE FROM questionnaire_prefill
WHERE questionnaire_prefill_id = '$questionnaire_prefill_id'";
$db->Execute($sql);
}
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
xhtml_head(T_("Pre fill questionnaire: Set values for questionnaire to prefill"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
print "<h3 class='form-inline pull-left'>" . T_("Select a questionnaire") . ":&emsp;</h3>";
$sql = "SELECT questionnaire_id as value,description,
CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM questionnaire
WHERE enabled = 1";
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline form-group");
if ($questionnaire_id != false)
{
print "<h2>" . T_("Current pre fills") . "</h2>";
$sql = "SELECT questionnaire_prefill_id,lime_sgqa,value
FROM questionnaire_prefill
WHERE questionnaire_id = '$questionnaire_id'";
$r = $db->GetAll($sql);
if (empty($r))
{
print "<p class='well text-info'>" . T_("Currently no pre fills") . "</p>";
}
else
{
foreach($r as $v)
{
print "<ul class='form-group clearfix'><p class='col-sm-2'>" . T_("SGQA code") . ":&emsp;<b class='text-primary'>{$v['lime_sgqa']}</b></p><p class='col-sm-4'>" . T_("Sample variable") . ":&emsp;<b class='text-primary'>{$v['value']}</b></p><a href='?questionnaire_id=$questionnaire_id&amp;questionnaire_prefill_id={$v['questionnaire_prefill_id']}'><i class='fa fa-lg text-danger'>" . T_("Delete") . "</i></a></ul>";
}
}
print "";
print "<h3 class='pull-left'>" . T_("Select a question to pre fill") . "&emsp;</h3>";
$sql = "SELECT lime_sid
FROM questionnaire
WHERE questionnaire_id = '$questionnaire_id'";
$r = $db->GetRow($sql);
$lime_sid = $r['lime_sid'];
$sgqa = false;
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
$sql = "SELECT CONCAT( q.sid, 'X', q.gid, 'X', q.qid) AS value,
CASE WHEN qo.question IS NULL THEN q.question ELSE CONCAT(qo.question,' : ',q.question) END as description,
CASE WHEN CONCAT(q.sid, 'X', q.gid, 'X', q.qid) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
FROM `" . LIME_PREFIX . "questions` AS q
LEFT JOIN `" . LIME_PREFIX . "questions` as qo ON (qo.qid = q.parent_qid)
WHERE q.sid = '$lime_sid'
ORDER BY CASE WHEN qo.question_order IS NULL THEN q.question_order ELSE qo.question_order + (q.question_order / 1000) END ASC";
$rs = $db->GetAll($sql);
for ($i=0; $i<count($rs); $i++)
{
$rs[$i]['description'] = substr(strip_tags($rs[$i]['description']),0,400);
}
display_chooser($rs,"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left");
print "<div class='clearfix'></div>";
if ($sgqa != false)
{
print "<h2 >" . T_("Enter a value to pre fill this question with:") . "</h2>";
print "<div class='well'><p>";
print T_("Possible uses:");
print "</p><ul>";
print "<li>" . T_("{Respondent:firstName} First name of the respondent") . "</li>";
print "<li>" . T_("{Respondent:lastName} Last name of the respondent") . "</li>";
print "<li>" . T_("{Sample:var} A record from the sample where the column name is 'var'") . "</li>";
print "</ul></div>";
$sql = "SELECT sv.var as description, CONCAT('{Sample:', sv.var, '}') as value
FROM `sample` AS s, sample_var AS sv, questionnaire_sample as qs
WHERE qs.questionnaire_id = '$questionnaire_id'
AND s.import_id = qs.sample_import_id
AND s.sample_id = sv.sample_id
GROUP BY sv.var";
?>
<form action="" method="get" class="form-inline form-group">
<label for="value"><?php echo T_("The value to pre fill"); ?>:&emsp;</label><input type="text" name="value" id="value" size="50" class="form-control"/>
<label for="svar">&emsp;<?php echo T_("or: Select pre fill from sample list"); ?>&emsp;</label>
<?php //display a list of possible sample variables for this questionnaire
display_chooser($db->GetAll($sql),"svar","svar",true,false,false,true,false,true,"form-group");
?>
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
<input type="hidden" name="sgqa" value="<?php print($sgqa); ?>"/>
<input type="submit" name="add_prefill" class="btn btn-primary fa" value="<?php print(T_("Add pre fill")); ?>"/>
</form>
<?php
}
}
xhtml_foot();
?>

View File

@@ -1,215 +1,216 @@
<?php /**
* Display sample call attempt report (A listing of how many attempts made for cases within a sample)
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
* @package queXS
* @subpackage admin
* @link http://www.acspri.org.au/ queXS was writen for ACSPRI
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include_once(dirname(__FILE__).'/../config.inc.php');
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
/**
* Generate the sample call attempt report
*
* @param mixed $questionnaire_id The quesitonnaire, if specified
* @param string $sample_id The sample, if speified
* @param mixed $qsqri THe questionnaire sample quota row id, if specified
*
* @return false if empty otherwise true if table drawn
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2012-10-02
*/
function sample_call_attempt_report($questionnaire_id = false, $sample_id = false, $qsqri = false)
{
global $db;
$q = "";
if ($questionnaire_id !== false && $questionnaire_id != -1)
$q = "AND c.questionnaire_id = $questionnaire_id";
$s = "";
if ($sample_id !== false)
$s = "JOIN sample as s ON (s.sample_id = c.sample_id AND s.import_id = '$sample_id')";
$qs = "";
if ($qsqri !== false)
$qs = "JOIN questionnaire_sample_quota_row as q ON (q.questionnaire_sample_quota_row_id = '$qsqri')
JOIN sample_var ON (sample_var.sample_id = c.sample_id AND sample_var.var LIKE q.exclude_var AND sample_var.val LIKE q.exclude_val)";
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
FROM ( SELECT count( ca.call_attempt_id ) AS ca1
FROM call_attempt as ca
JOIN `case` as c ON (c.case_id = ca.case_id $q)
$s
$qs
GROUP BY ca.case_id) AS t1
GROUP BY ca1";
$overall = $db->GetAll($sql);
if (empty($overall))
return false;
$sql = "SELECT outcome_id,description
FROM outcome";
$outcomes = $db->GetAssoc($sql);
translate_array($outcomes,array("description"));
$rep = array("sample","callattempts");
$rept = array(T_("Number of cases"),T_("Call attempts made"));
$totals = array("sample");
$outcomesfilled = array();
foreach($outcomes as $key => $val)
{
$rep[] = $key;
$rept[] = $val;
$outcomesfilled[$key] = 0;
}
//Add breakdown by call attempt
for ($i = 0; $i < count($overall); $i++)
{
//break down by outcome
$sql = "SELECT oi1, ca1 as callattempts, count(ca1) as sample
FROM ( SELECT count( ca.call_attempt_id ) AS ca1, ca.case_id, c.current_outcome_id as oi1
FROM call_attempt AS ca
JOIN `case` AS c ON ( c.case_id = ca.case_id $q)
$s
$qs
GROUP BY ca.case_id
) as t1
GROUP BY ca1,oi1
HAVING ca1 = {$overall[$i]['callattempts']}";
$byoutcome = $db->GetAssoc($sql);
foreach($outcomes as $key => $val)
{
$sample = 0;
if (isset($byoutcome[$key]))
{
$outcomesfilled[$key] = 1;
$sample = $byoutcome[$key]['sample'];
}
$overall[$i][$key] = $sample;
}
}
//Remove columns that are empty
$count = 2;
foreach ($outcomesfilled as $key => $val)
{
if ($val == 0)
{
unset($rep[$count]);
unset($rept[$count]);
}
else
$totals[] = $key;
$count++;
}
xhtml_table($overall,$rep,$rept,"tclass",false,$totals);
return true;
}
xhtml_head(T_("Sample call attempt"),true,array("../css/table.css"),array("../js/window.js"));
print "<h2>" . T_("Please select a questionnaire") . "</h2>";
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = intval($_GET['questionnaire_id']);
display_questionnaire_chooser($questionnaire_id,array(-1,T_("Overall")));
if ($questionnaire_id || $questionnaire_id == -1)
{
if (sample_call_attempt_report($questionnaire_id,false,false))
{
if ($questionnaire_id != -1)
{
print "<h2>" . T_("Please select a sample") . "</h2>";
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
display_sample_chooser($questionnaire_id,$sample_import_id);
if ($sample_import_id)
{
if (sample_call_attempt_report($questionnaire_id,$sample_import_id,false))
{
$questionnaire_sample_quota_row_id = false;
if (isset($_GET['questionnaire_sample_quota_row_id'])) $questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
print "<h2>" . T_("Please select a quota") . "</h2>";
display_quota_chooser($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id);
if ($questionnaire_sample_quota_row_id)
{
if (!sample_call_attempt_report($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id))
print "<p>" . T_("No calls for this quota") . "</p>";
}
}
else
print "<p>" . T_("No calls for this sample") . "</p>";
}
}
}
else
print "<p>" . T_("No calls for this questionnaire") . "</p>";
}
xhtml_foot();
?>
<?php /**
* Display sample call attempt report (A listing of how many attempts made for cases within a sample)
*
*
* This file is part of queXS
*
* queXS is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* queXS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with queXS; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
* @package queXS
* @subpackage admin
* @link http://www.acspri.org.au/ queXS was writen for ACSPRI
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
*
*/
/**
* Configuration file
*/
include_once(dirname(__FILE__).'/../config.inc.php');
/**
* Database file
*/
include ("../db.inc.php");
/**
* XHTML functions
*/
include ("../functions/functions.xhtml.php");
/**
* Display functions
*/
include("../functions/functions.display.php");
/**
* Input functions
*/
include("../functions/functions.input.php");
/**
* Generate the sample call attempt report
*
* @param mixed $questionnaire_id The quesitonnaire, if specified
* @param string $sample_id The sample, if speified
* @param mixed $qsqri THe questionnaire sample quota row id, if specified
*
* @return false if empty otherwise true if table drawn
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2012-10-02
*/
function sample_call_attempt_report($questionnaire_id = false, $sample_id = false, $qsqri = false)
{
global $db;
$q = "";
if ($questionnaire_id !== false && $questionnaire_id != -1)
$q = "AND c.questionnaire_id = $questionnaire_id";
$s = "";
if ($sample_id !== false)
$s = "JOIN sample as s ON (s.sample_id = c.sample_id AND s.import_id = '$sample_id')";
$qs = "";
if ($qsqri !== false)
$qs = "JOIN questionnaire_sample_quota_row as q ON (q.questionnaire_sample_quota_row_id = '$qsqri')
JOIN sample_var ON (sample_var.sample_id = c.sample_id AND sample_var.var LIKE q.exclude_var AND sample_var.val LIKE q.exclude_val)";
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
FROM ( SELECT count( ca.call_attempt_id ) AS ca1
FROM call_attempt as ca
JOIN `case` as c ON (c.case_id = ca.case_id $q)
$s
$qs
GROUP BY ca.case_id) AS t1
GROUP BY ca1";
$overall = $db->GetAll($sql);
if (empty($overall))
return false;
$sql = "SELECT outcome_id,description
FROM outcome";
$outcomes = $db->GetAssoc($sql);
translate_array($outcomes,array("description"));
$rep = array("callattempts","sample");
$rept = array(T_("Call attempts made"),T_("Number of cases"));
$totals = array("sample");
$outcomesfilled = array();
foreach($outcomes as $key => $val)
{
$rep[] = $key;
$rept[] = $val;
$outcomesfilled[$key] = 0;
}
//Add breakdown by call attempt
for ($i = 0; $i < count($overall); $i++)
{
//break down by outcome
$sql = "SELECT oi1, ca1 as callattempts, count(ca1) as sample
FROM ( SELECT count( ca.call_attempt_id ) AS ca1, ca.case_id, c.current_outcome_id as oi1
FROM call_attempt AS ca
JOIN `case` AS c ON ( c.case_id = ca.case_id $q)
$s
$qs
GROUP BY ca.case_id
) as t1
GROUP BY ca1,oi1
HAVING ca1 = {$overall[$i]['callattempts']}";
$byoutcome = $db->GetAssoc($sql);
foreach($outcomes as $key => $val)
{
$sample = 0;
if (isset($byoutcome[$key]))
{
$outcomesfilled[$key] = 1;
$sample = $byoutcome[$key]['sample'];
}
$overall[$i][$key] = $sample;
}
}
//Remove columns that are empty
$count = 2;
foreach ($outcomesfilled as $key => $val)
{
if ($val == 0)
{
unset($rep[$count]);
unset($rept[$count]);
}
else
$totals[] = $key;
$count++;
}
xhtml_table($overall,$rep,$rept,"tclass",false,$totals);
print "</br>";
return true;
}
xhtml_head(T_("Sample call attempt"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
print "<h3 class='form-inline pull-left'>" . T_("Please select a questionnaire") . "&emsp;</h3>";
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) $questionnaire_id = intval($_GET['questionnaire_id']);
display_questionnaire_chooser($questionnaire_id,array(-1,T_("Overall")),"form-inline clearfix", "form-control");
if ($questionnaire_id || $questionnaire_id == -1)
{
if (sample_call_attempt_report($questionnaire_id,false,false))
{
if ($questionnaire_id != -1)
{
print "<h3 class='form-inline pull-left'>" . T_("Please select a sample") . "&emsp;</h3>";
$sample_import_id = false;
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
display_sample_chooser($questionnaire_id,$sample_import_id,false,"form-inline clearfix", "form-control");
if ($sample_import_id)
{
if (sample_call_attempt_report($questionnaire_id,$sample_import_id,false))
{
$questionnaire_sample_quota_row_id = false;
if (isset($_GET['questionnaire_sample_quota_row_id'])) $questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
print "<h3 class='form-inline pull-left'>" . T_("Please select a quota") . "&emsp;</h3>";
display_quota_chooser($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id,"form-inline clearfix", "form-control");
if ($questionnaire_sample_quota_row_id)
{
if (!sample_call_attempt_report($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id))
print "<p class='well text-danger'>" . T_("No calls for this quota") . "</p>";
}
}
else
print "<p class='well text-danger'>" . T_("No calls for this sample") . "</p>";
}
}
}
else
print "<p class='well text-danger'>" . T_("No calls for this questionnaire") . "</p>";
}
xhtml_foot();
?>