mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
fixed issues after merging with rev.448 to operate with var_id and exclude_var_id instead of sample_var
* removed "Go back" href url , use js function " onclick='history.back();return false;' " ( fix bug #1472568) (Feature) * added SGQ code to questions selector (fix bug #1472581) * fixed questions selector sorting (fix bug #1472581) (Feature) * added answer code table for resriction question selected, if exist (Feature) * hide "add restriction" if no question or sample variable selected (Feature) * added import .csv files restriction depending on user_agent *added+changed Info messages for restriction blocks * added input fields for "Description" in both restriction blocks by sample and by question, added table column for "Description" values, sql qerries adjusted replaced standart checkbox with Icheck / toggle button replaced fileinput with "filestyle.js" reworked page layout , adjusted to "Featue" Bootstrap layout need to update Changelog and quexs.sql
This commit is contained in:
@@ -103,7 +103,7 @@ if (isset($_POST['submitexport']))
|
||||
|
||||
$q2 = $db->GetAll($sql);
|
||||
|
||||
$sql = "SELECT exclude_var as samplerecord,comparison,exclude_val as value
|
||||
$sql = "SELECT exclude_var_id, exclude_var as samplerecord,comparison,exclude_val as value
|
||||
FROM qsqr_sample
|
||||
WHERE questionnaire_sample_quota_row_id = $tmp";
|
||||
|
||||
@@ -248,12 +248,15 @@ if (isset($_GET['qsqri']) & isset($_GET['edit']))
|
||||
|
||||
if (isset($_POST['adds']))
|
||||
{
|
||||
$comparison = $db->qstr($_POST['comparisons']);
|
||||
$exvar = $db->qstr(substr($_POST['sample_var'],12,strpos($_POST['sample_var'],'&')-12));
|
||||
$exvar_id = $db->qstr(substr($_POST['sample_var_id'],15,strpos($_POST['sample_var_id'],'&')-15));
|
||||
$exvar = $db->qstr($_POST['sample_var']);
|
||||
$exval = $db->qstr($_POST['exclude_val']);
|
||||
$comparison = $db->qstr($_POST['comparisons']);
|
||||
$description = $db->qstr($_POST['description']);
|
||||
|
||||
//add ssample
|
||||
$sql = "INSERT INTO qsqr_sample (questionnaire_sample_quota_row_id,exclude_var,exclude_val,comparison)
|
||||
VALUES ($qsqri,$exvar,$exval,$comparison)";
|
||||
$sql = "INSERT INTO qsqr_sample (questionnaire_sample_quota_row_id,exclude_var_id,exclude_var,exclude_val,comparison,description)
|
||||
VALUES ($qsqri,$exvar_id,$exvar,$exval,$comparison,$description)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
@@ -263,12 +266,13 @@ if (isset($_GET['qsqri']) & isset($_GET['edit']))
|
||||
|
||||
if (isset($_POST['addq']))
|
||||
{
|
||||
$comparison = $db->qstr($_POST['comparison']);
|
||||
$value = $db->qstr($_POST['value']);
|
||||
$sgqa = $db->qstr(substr($_POST['sgqa'],6,strpos($_POST['sgqa'],'&')-6));
|
||||
$value = $db->qstr($_POST['value']);
|
||||
$comparison = $db->qstr($_POST['comparison']);
|
||||
$description = $db->qstr($_POST['description']);
|
||||
//add ssample
|
||||
$sql = "INSERT INTO qsqr_question (questionnaire_sample_quota_row_id,lime_sgqa,value,comparison)
|
||||
VALUES ($qsqri,$sgqa,$value,$comparison)";
|
||||
$sql = "INSERT INTO qsqr_question (questionnaire_sample_quota_row_id,lime_sgqa,value,comparison,description)
|
||||
VALUES ($qsqri,$sgqa,$value,$comparison,$description)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
@@ -280,7 +284,7 @@ if (isset($_GET['qsqri']) & isset($_GET['edit']))
|
||||
$questionnaire_id = false;
|
||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
|
||||
xhtml_head(T_("Quota row management"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../js/window.js"));
|
||||
xhtml_head(T_("Quota row management"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css","../include/font-awesome-4.3.0/css/font-awesome.css","../include/iCheck/skins/square/blue.css","../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js","../include/iCheck/icheck.min.js","../js/window.js"));
|
||||
print "<h3 class='form-inline pull-left'>" . T_("Questionnaire") . ": </h3>";
|
||||
|
||||
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
@@ -293,8 +297,6 @@ if ($questionnaire_id != false)
|
||||
{
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
|
||||
print "<h1>" . T_("Select a sample from the list below") . "</h1>";
|
||||
|
||||
$sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
FROM sample_import as s, questionnaire_sample as q
|
||||
@@ -323,10 +325,10 @@ if ($questionnaire_id != false)
|
||||
if (count($data) > 2)
|
||||
{
|
||||
//one quota record per row
|
||||
$completions = intval($data[1]);
|
||||
$description = $db->quote($data[0]);
|
||||
$completions = intval($data[1]);
|
||||
$autoprioritise = 0;
|
||||
if ($data[2] != 0) $autoprioritise = 1;
|
||||
$description = $db->quote($data[0]);
|
||||
|
||||
$sql = "INSERT INTO questionnaire_sample_quota_row(questionnaire_id, sample_import_id, completions, description, priority, autoprioritise)
|
||||
VALUES ($questionnaire_id, $sample_import_id, $completions, $description, 50, $autoprioritise)";
|
||||
@@ -355,12 +357,13 @@ if ($questionnaire_id != false)
|
||||
else
|
||||
{
|
||||
//is a sample variable
|
||||
$comparison = $db->qstr($data[($i*3) + 1]);
|
||||
$value = $db->qstr($data[($i*3) + 2]);
|
||||
$var = $db->qstr($data[$i*3]);
|
||||
$var_id = $db->qstr($data[$i*3]);
|
||||
$var = $db->qstr($data[($i*3) + 1]);
|
||||
$comparison = $db->qstr($data[($i*3) + 2]);
|
||||
$value = $db->qstr($data[($i*3) + 3]);
|
||||
|
||||
$sql = "INSERT INTO qsqr_sample (questionnaire_sample_quota_row_id,exclude_var,exclude_val,comparison)
|
||||
VALUES ($qq,$var,$value,$comparison)";
|
||||
$sql = "INSERT INTO qsqr_sample (questionnaire_sample_quota_row_id,exclude_var_id,exclude_var,exclude_val,comparison)
|
||||
VALUES ($qq,$var_id,$var,$value,$comparison)";
|
||||
|
||||
$db->Execute($sql);
|
||||
}
|
||||
@@ -375,23 +378,22 @@ if ($questionnaire_id != false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($qsqri != false)
|
||||
{
|
||||
print "<h2 class='col-sm-2 '><a href='' onclick='history.back();return false;' class='btn btn-default'><i class='fa fa-chevron-left fa-lg text-primary'></i> " . T_("Go back") . "</a></h2>";
|
||||
print "<h2>" . T_("Quota") . ": $qsqrid</h2>";
|
||||
print "<p><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id'>" . T_("Go back") . "</a></p>";
|
||||
|
||||
|
||||
?>
|
||||
<form action="?<?php echo "questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id"; ?>" method="post">
|
||||
<p>
|
||||
<label for="description"><?php echo T_("Describe this quota"); ?> </label><input type="text" name="description" id="description" value="<?php echo $qsqrid;?>"/> <br/>
|
||||
<label for="priority"><?php echo T_("Quota priority (50 is default, 100 highest, 0 lowest)"); ?> </label><input type="text" name="priority" id="priority" value="<?php echo $qsqrip;?>"/> <br/>
|
||||
<label for="autoprioritise"><?php echo T_("Should the priority be automatically updated based on the number of completions in this quota?"); ?> </label><input type="checkbox" name="autoprioritise" id="autoprioritise" <?php echo $qsqrich; ?>/> <br/>
|
||||
<label for="completions"><?php echo T_("The number of completions to stop calling at"); ?> </label><input type="text" name="completions" id="completions" value="<?php echo $qsqric; ?>"/> <br/>
|
||||
<div class='panel-body' >
|
||||
<form action="?<?php echo "questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id"; ?>" method="post" class="form-inline table">
|
||||
<p><label for="description" class="control-label"><?php echo T_("Describe this quota"); ?>: </label><input type="text" name="description" id="description" class="form-control" value="<?php echo $qsqrid;?>" required size="70"/></p>
|
||||
<p><label for="priority" class="control-label"><?php echo T_("Quota priority (50 is default, 100 highest, 0 lowest)"); ?>: </label><input type="number" class="form-control" name="priority" id="priority" value="<?php echo $qsqrip;?>" min="0" max="100" style="width:5em;"/></p>
|
||||
<p><label for="completions" class="control-label"><?php echo T_("The number of completions to stop calling at"); ?>: </label><input type="number" class="form-control" name="completions" id="completions" value="<?php echo $qsqric; ?>" min="0" size="6" maxlength="6" style="width:6em;" required /></p>
|
||||
<p><label for="autoprioritise" class="control-label"><?php echo T_("Should the priority be automatically updated based on the number of completions in this quota?"); ?> </label><input type="checkbox" name="autoprioritise" id="autoprioritise" <?php echo $qsqrich; ?>data-toggle="toggle" data-on="<?php echo T_("Yes"); ?>" data-off="<?php echo T_("No"); ?>" data-offstyle="warning"/></p>
|
||||
<input type="hidden" name="qsqri" value="<?php echo $qsqri; ?>"/>
|
||||
<input type="submit" name="edit_quota" value="<?php print(T_("Edit row quota")); ?>"/></p>
|
||||
<p><button type="submit" name="edit_quota" class="btn btn-primary"><?php print(T_("Save changes")); ?></button></p>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
//display questionnaire references
|
||||
@@ -399,18 +401,22 @@ if ($questionnaire_id != false)
|
||||
CONCAT('<a href=\'?edit=edit&qsqri=$qsqri&delete=delete&qsqrqi=', qsqr_question_id, '\'>" . TQ_("Delete") . "</a>') as qdelete
|
||||
FROM qsqr_question
|
||||
WHERE questionnaire_sample_quota_row_id = $qsqri";
|
||||
|
||||
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
|
||||
print "<div class='panel panel-default'>";
|
||||
print "<div class='panel-heading'><h3 class='text-center'>" . T_("Restrictions based on answered questions") . "</h3></div>";
|
||||
print "<div class='panel-body'>";
|
||||
|
||||
if (empty($rs))
|
||||
{
|
||||
print "<h3>" . T_("All completed responses that match the sample criteria below will be counted towards the quota") . "</h3>";
|
||||
print "<h4 class='well text-info'>" . T_("Currently NO Restrictions based on answered questions") . " </p>" . T_("All completed responses that match the sample criteria below will be counted towards the quota") . "</h4>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<h3>" . T_("Only completed responses that have answered the following will be counted") . "</h3>";
|
||||
xhtml_table($rs,array('lime_sgqa','comparison','value','qdelete'),array(T_("Question"),T_("Comparison"),T_("Value"),T_("Delete")));
|
||||
print "<div class='well'><h4 class='text-info'>" . T_("Only completed responses that have answered the following will be counted") . "</h4>";
|
||||
xhtml_table($rs,array('description','lime_sgqa','comparison','value','qdelete'),array(T_("Description"),T_("SGQ code"),T_("Comparison"),T_("Value"),T_("Delete")));
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
//add questionnaire references if any (refer to sample only or count completions based on responses to questions)
|
||||
@@ -426,101 +432,138 @@ if ($questionnaire_id != false)
|
||||
$ssgqa = $db->qstr($_GET['sgqa']);
|
||||
|
||||
//select question
|
||||
$sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ': ', lq.question) END as description, CASE WHEN $ssgqa LIKE CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
$sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END, ' -> ' , CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ' : ', lq.question) END) as description, CASE WHEN $ssgqa LIKE CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
FROM `" . LIME_PREFIX . "questions` AS lq
|
||||
LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid )
|
||||
JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid)
|
||||
WHERE lq.sid = '$lime_sid'
|
||||
ORDER BY g.group_order ASC, lq.question_order ASC";
|
||||
ORDER BY CASE WHEN lq2.question_order IS NULL THEN lq.question_order ELSE lq2.question_order + (lq.question_order / 1000) END ASC";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
$rsgqa = $db->GetAll($sql);
|
||||
|
||||
if (!empty($rs))
|
||||
if (!empty($rsgqa))
|
||||
{
|
||||
print "<form method='post' action='?qsqri=$qsqri&edit=edit'>";
|
||||
print "<h4>" . T_("Add restriction based on answered questions") . "</h4>";
|
||||
print "<label for='sgqa'>" . T_("Question") . "</label>";
|
||||
display_chooser($rs,"sgqa","sgqa",false,"edit=edit&qsqri=$qsqri",true,false);
|
||||
print "<div class=''><form method='post' action='?qsqri=$qsqri&edit=edit' class='form-group'>";
|
||||
print "<h3>" . T_("Add restriction based on answered questions") . " </h3>";
|
||||
print "<label for='sgqa' class='control-label'>" . T_("Select Question") . ": </label>";
|
||||
display_chooser($rsgqa,"sgqa","sgqa",true,"edit=edit&qsqri=$qsqri");
|
||||
|
||||
if (isset($_GET['sgqa'])){
|
||||
?>
|
||||
<br/><label for="comparison"><?php echo T_("The type of comparison"); ?></label><select name="comparison" id="comparison"><option value="LIKE">LIKE</option><option value="NOT LIKE">NOT LIKE</option><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option></select><br/>
|
||||
<label for="value"><?php echo T_("The code value to compare"); ?> </label><input type="text" name="value" id="value"/> <br/>
|
||||
<input type="submit" name="addq" value="<?php echo TQ_("Add restriction") ?>"/>
|
||||
</form>
|
||||
<div class='col-sm-6 panel-body form-inline'>
|
||||
<p><label for="description" class="control-label"><?php echo T_("Description"); ?>: </label><input type="text" class="form-control" name="description" id="description" size="80"/></p>
|
||||
<p><label for="comparison" class="control-label"><?php echo T_("The type of comparison"); ?>: </label>
|
||||
<select name="comparison" class="form-control" id="comparison"><option value="LIKE">LIKE</option><option value="NOT LIKE">NOT LIKE</option><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option></select>
|
||||
</p>
|
||||
<p><label for="value" class="control-label"><?php echo T_("The code value to compare"); ?>: </label><input type="text" name="value" id="value" class="form-control" required /></p>
|
||||
<p><button type="submit" name="addq" class="btn btn-primary"/><?php echo TQ_("Add restriction") ?></button></p>
|
||||
</div></form>
|
||||
<?php
|
||||
|
||||
print "<div class='col-sm-6 '><h4 class= 'pull-left'>" . T_("Code values for this question") . ": </h4>";
|
||||
|
||||
$rs = "";
|
||||
if (isset($_GET['sgqa']))
|
||||
{
|
||||
$sgqa = $_GET['sgqa'];
|
||||
$qid = explode("X", $sgqa);
|
||||
$qid = $qid[2];
|
||||
|
||||
$sql = "SELECT CONCAT('<b class=\'fa\'> ', l.code , '</b>')as code, l.answer as title
|
||||
FROM `" . LIME_PREFIX . "answers` as l
|
||||
WHERE l.qid = '$qid'";
|
||||
$rsc = $db->GetAll($sql);
|
||||
}
|
||||
if (!isset($rsc) || empty($rsc))
|
||||
print "<h4 class= 'alert alert-info'>" . T_("No labels defined for this question") ."</h4>";
|
||||
else
|
||||
xhtml_table($rsc,array('code','title'),array(T_("Code value"), T_("Description")));
|
||||
}
|
||||
else { print "</form>"; }
|
||||
print "</div></div>";
|
||||
}
|
||||
|
||||
print "</div></div>";
|
||||
|
||||
//list sample records to exclude
|
||||
|
||||
$sql = "SELECT qsqr_sample_id,exclude_var,exclude_val,comparison,description,
|
||||
CONCAT('<a href=\'?qsqri=$qsqri&edit=edit&delete=delete&qsqrsi=',qsqr_sample_id,'\'>" . TQ_("Delete") . "</a>') as sdelete
|
||||
$sql = "SELECT qsqr_sample_id,exclude_var_id,exclude_var,exclude_val,comparison,description,
|
||||
CONCAT('<a href=\'?qsqri=$qsqri&edit=edit&delete=delete&qsqrsi=',qsqr_sample_id,'\'><i class=\"fa fa-trash-o fa-lg text-danger\"></i> " . TQ_("Delete") . "</a>') as sdelete
|
||||
FROM qsqr_sample
|
||||
WHERE questionnaire_sample_quota_row_id = $qsqri";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
|
||||
print "<div class='panel panel-default'>";
|
||||
print "<div class='panel-heading'><h3 class='text-center'>" . T_("Restrictions based on sample records") . "</h3></div>";
|
||||
print "<div class='panel-body'>";
|
||||
if (empty($rs))
|
||||
{
|
||||
print "<h3>" . T_("All sample records will be excluded") . "</h3>";
|
||||
print "<h4 class='well text-info'>" . T_("Currently NO Restrictions based on sample records") . " </p>" . T_("This sample will be limited to number of competions set in quota") . " </p>" . T_("Caling cases for this sample will be stopped when the quota is reached") . "</h4>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<h3>" . T_("Completed responses that have the following sample details will be counted towards the quota and excluded when the quota is reached") . "</h3>";
|
||||
xhtml_table($rs,array('exclude_var','comparison','exclude_val','sdelete'),array(T_("Sample record"),T_("Comparison"),T_("Value"),T_("Delete")));
|
||||
print "<div class='well'><h4 class='text-info'>" . T_("Completed responses that have the following sample details will be counted towards the quota and excluded when the quota is reached") . "</h4>";
|
||||
xhtml_table($rs,array('description','exclude_var_id','exclude_var','comparison','exclude_val','sdelete'),array(T_("Description"),T_("Sample var ID"),T_("Sample variable"),T_("Comparison"),T_("Value"),T_("Delete")));
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
$ssample_var = "''";
|
||||
if (isset($_GET['sample_var']))
|
||||
$ssample_var = $db->qstr($_GET['sample_var']);
|
||||
$ssample_var_id = "''";
|
||||
if (isset($_GET['sample_var_id'])) $ssample_var_id = $db->qstr($_GET['sample_var_id']);
|
||||
|
||||
//add sample references (records from sample to exclude when quota reached)
|
||||
$sql = "SELECT sv.var as value, sv.var as description, CASE WHEN sv.var LIKE $ssample_var THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
FROM sample_var AS sv, sample AS s
|
||||
WHERE s.import_id = $sample_import_id
|
||||
$sql = "SELECT sivr.var_id as value, sivr.var as description,
|
||||
CASE WHEN sivr.var_id = $ssample_var_id THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
FROM `sample_import_var_restrict` as sivr, `sample_var` AS sv, `sample` AS s
|
||||
WHERE sivr.sample_import_id = $sample_import_id
|
||||
AND s.sample_id = sv.sample_id
|
||||
GROUP BY sv.var";
|
||||
AND sivr.var_id = sv.var_id
|
||||
GROUP BY sivr.var_id";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
$rsvi = $db->GetAll($sql);
|
||||
|
||||
if (!empty($rs))
|
||||
if (!empty($rsvi))
|
||||
{
|
||||
if ($ssample_var == "''")
|
||||
$ssample_var = "'" . $rs[0]['value']. "'";
|
||||
if ($ssample_var_id == "''")
|
||||
$ssample_var_id = $rsvi[0]['value'];
|
||||
|
||||
print "<h4>" . T_("Add restriction based on sample records") . "</h4>";
|
||||
print "<form method='post' action='?edit=edit&qsqri=$qsqri'>";
|
||||
print "<label for='sample_var'>" . T_("Sample record") . "</label>";
|
||||
display_chooser($rs,"sample_var","sample_var",false,"edit=edit&qsqri=$qsqri",true,false);
|
||||
?>
|
||||
<br/><label for="comparisons"><?php echo T_("The type of comparison"); ?></label><select name="comparisons" id="comparisons"><option value="LIKE">LIKE</option><option value="NOT LIKE">NOT LIKE</option><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option></select><br/>
|
||||
<label for="exclude_val"><?php echo T_("Value"); ?></label>
|
||||
<?php
|
||||
|
||||
$sql = "SELECT sv.val as value, sv.val as description, '' AS selected
|
||||
FROM sample_var AS sv, sample AS s
|
||||
WHERE s.import_id = $sample_import_id
|
||||
AND s.sample_id = sv.sample_id
|
||||
AND sv.var = $ssample_var
|
||||
GROUP BY sv.val";
|
||||
|
||||
display_chooser($db->GetAll($sql),"exclude_val","exclude_val",false,false,false,false);
|
||||
flush();
|
||||
?>
|
||||
<br/><input type="submit" name="adds" value="<?php echo TQ_("Add restriction") ?>"/>
|
||||
</form>
|
||||
print "<h3>" . T_("Add restriction based on sample records") . "</h3>";
|
||||
print "<form method='post' action='?edit=edit&qsqri=$qsqri' class='form-inline table'>";
|
||||
print "<p><label for='sample_var' class='control-label'>" . T_("Sample record") . "</label>: ";
|
||||
display_chooser($rsvi,"sample_var_id","sample_var_id",true,"edit=edit&qsqri=$qsqri",true,false);
|
||||
|
||||
if (isset($_GET['sample_var_id'])){
|
||||
?>
|
||||
|
||||
 <label for="comparisons" class="control-label"><?php echo T_("The type of comparison"); ?></label>: <select name="comparisons" id="comparisons" class="form-control"><option value="LIKE">LIKE</option><option value="NOT LIKE">NOT LIKE</option><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option></select> 
|
||||
<label for="exclude_val" class="control-label"><?php echo T_("Value"); ?>: </label>
|
||||
<?php
|
||||
$sql = "SELECT sv.val as value, sv.val as description, '' AS selected, sivr.var as var
|
||||
FROM sample_var AS sv, sample AS s, `sample_import_var_restrict` as sivr
|
||||
WHERE s.import_id = $sample_import_id
|
||||
AND s.sample_id = sv.sample_id
|
||||
AND sv.var_id = $ssample_var_id
|
||||
AND sivr.var_id = sv.var_id
|
||||
GROUP BY sv.val";
|
||||
$val = $db->GetAll($sql);
|
||||
$sample_var = $val[0]['var'];
|
||||
display_chooser($val,"exclude_val","exclude_val",false,false,false,false);
|
||||
flush();
|
||||
?>
|
||||
 </p>
|
||||
<p><label for="description" class="control-label"><?php echo T_("Description"); ?>: </label><input type="text" class="form-control" name="description" id="description" size="80"/></p>
|
||||
<input type="hidden" name="sample_var" value="<?php print $sample_var; ?>"/>
|
||||
<input type="submit" class="btn btn-primary" name="adds" value="<?php echo TQ_("Add restriction"); ?>"/>
|
||||
<?php
|
||||
} else { print "</p>";}
|
||||
print "</form>";
|
||||
}
|
||||
print "</div></div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
print "<h1>" . T_("Current row quotas (click to edit)") . "</h1>";
|
||||
|
||||
|
||||
$sql = "SELECT questionnaire_sample_quota_row_id,qsq.description,
|
||||
$sql = "SELECT questionnaire_sample_quota_row_id,qsq.description,
|
||||
CONCAT('<a href=\'?edit=edit&qsqri=',questionnaire_sample_quota_row_id,'\'>', qsq.description, '</a>') as qedit,
|
||||
CONCAT('<input type=\'checkbox\' name=\'select_',questionnaire_sample_quota_row_id,'\'/>') as qselect,
|
||||
CONCAT('<div class=\'text-center\'><input type=\'checkbox\' name=\'select_',questionnaire_sample_quota_row_id,'\'/></div>') as qselect,
|
||||
qsq.completions,qsq.quota_reached,qsq.current_completions,
|
||||
CASE WHEN qsq.autoprioritise = 1 THEN '" . TQ_("Yes") . "' ELSE '" . TQ_("No") . "' END AS ap, qsq.priority,
|
||||
CASE WHEN qsq.quota_reached = 1 THEN '" . TQ_("closed") . "' ELSE '" . TQ_("open") . "' END AS status
|
||||
@@ -528,48 +571,58 @@ if ($questionnaire_id != false)
|
||||
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
||||
AND qsq.sample_import_id = '$sample_import_id'
|
||||
AND q.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
print "<form method='post' action='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id'>";
|
||||
if (empty($r))
|
||||
{
|
||||
print "<p>" . T_("Currently no row quotas") . "</p>";
|
||||
print "<p class='well text-info'>" . T_("Currently no row quotas") . "</p>";
|
||||
}
|
||||
else
|
||||
{
|
||||
xhtml_table($r,array('qedit','completions','current_completions','status','priority','ap','qselect'),array(T_("Description"),T_("Quota"),T_("Completions"),T_("Status"),T_("Priority"),T_("Auto prioritise"),T_("Select")));
|
||||
print "<input type='submit' name='submitdelete' value='" . TQ_("Delete selected") . "'/>";
|
||||
print "<input type='submit' name='submitexport' value='" . TQ_("Export selected") . "'/>";
|
||||
|
||||
//select sample
|
||||
|
||||
print "<form method='post' action='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id'>";
|
||||
print "<div class='col-sm-12 panel-body'></br><h2>" . T_("Current row quotas (click to edit)") . "</h2><div class='pull-left'>";
|
||||
xhtml_table($r,array('qedit','completions','current_completions','status','priority','ap','qselect'),array(T_("Description"),T_("Quota"),T_("Completions"),T_("Status"),T_("Priority"),T_("Auto prioritise"),T_("Select")));
|
||||
print "</div><div class='pull-left'></br>";
|
||||
print "<button class='btn btn-default col-sm-offset-2' type='submit' name='submitexport'><i class=\"fa fa-download fa-lg text-primary\"></i> " . TQ_("Export selected") . "</button></br></br>";
|
||||
print "<button class='btn btn-default col-sm-offset-2' type='submit' name='submitdelete'><i class=\"fa fa-trash-o fa-lg text-danger\"></i> 
|
||||
" . TQ_("Delete selected") . "</button></div></div>";
|
||||
print "</form>";
|
||||
}
|
||||
print "</form>";
|
||||
print "<h2>" . T_("Add row quota") . "</h2>";
|
||||
?>
|
||||
<form action="?<?php echo "questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id"; ?>" method="post">
|
||||
<p>
|
||||
<label for="description"><?php echo T_("Describe this quota"); ?> </label><input type="text" name="description" id="description"/> <br/>
|
||||
<label for="priority"><?php echo T_("Quota priority (50 is default, 100 highest, 0 lowest)"); ?> </label><input type="text" name="priority" id="priority" value="50"/> <br/>
|
||||
<label for="autoprioritise"><?php echo T_("Should the priority be automatically updated based on the number of completions in this quota?"); ?> </label><input type="checkbox" name="autoprioritise" id="autoprioritise"/> <br/>
|
||||
<label for="completions"><?php echo T_("The number of completions to stop calling at"); ?> </label><input type="text" name="completions" id="completions"/> <br/>
|
||||
<input type="submit" name="add_quota" value="<?php print(T_("Add row quota")); ?>"/></p>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
print "<h2>" . T_("Import row quota") . "</h2>";
|
||||
print "<div class='col-sm-8 panel-body'><h2>" . T_("Add row quota") . "</h2>";
|
||||
?>
|
||||
<form enctype="multipart/form-data" action="<?php echo "?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id"; ?>" method="post">
|
||||
<p><input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></p>
|
||||
<p><?php echo T_("Choose the CSV row quota file to import:"); ?><input name="file" type="file" /></p>
|
||||
<p><input type="submit" name="import_quota" value="<?php print(T_("Import row quota")); ?>"/></p>
|
||||
</form>
|
||||
<form action="?<?php echo "questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id"; ?>" method="post" class="form-inline table">
|
||||
<p><label for="description" class="control-label"><?php echo T_("Describe this quota"); ?>:  </label><input type="text" class="form-control" name="description" id="description" required size="70"/></p>
|
||||
<p><label for="priority" class="control-label"><?php echo T_("Quota priority (50 is default, 100 highest, 0 lowest)"); ?>: </label><input type="number" class="form-control" name="priority" id="priority" value="50" min="0" max="100" style="width:5em;"/></p>
|
||||
<p><label for="completions" class="control-label"><?php echo T_("The number of completions to stop calling at"); ?>: </label><input type="number" class="form-control" name="completions" id="completions" min="0" size="6" maxlength="6" style="width:6em;" required/></p>
|
||||
<p><label for="autoprioritise" class="control-label"><?php echo T_("Should the priority be automatically updated based on the number of completions in this quota?"); ?>  </label><input type="checkbox" name="autoprioritise" id="autoprioritise" data-toggle="toggle" data-on="<?php echo T_("Yes"); ?>" data-off="<?php echo T_("No"); ?>" data-offstyle="warning"/></p>
|
||||
<p><input type="submit" class="btn btn-primary" name="add_quota" value="<?php print(T_("Add row quota")); ?>"/></p>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
//check user agent to properly filter *.csv file type
|
||||
print "<div class='col-sm-4 panel-body'><h2>" . T_("Import row quota") . "</h2>";
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv";
|
||||
?>
|
||||
<form enctype="multipart/form-data" action="<?php echo "?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id"; ?>" method="post">
|
||||
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
|
||||
<h4><?php echo T_("Choose the CSV row quota file to import:"); ?></h4>
|
||||
<p><input id="file" name="file" type="file" class="filestyle form-group" required data-buttonBefore="true" data-iconName="fa fa-folder-open fa-lg text-primary " data-buttonText="<?php echo T_("Select file"); ?>..." accept="<?php echo $csv; ?>"/></p>
|
||||
<button type="submit" class="btn btn-primary" name="import_quota" ><?php print(T_("Import row quota")); ?></button>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
xhtml_foot();
|
||||
|
||||
xhtml_foot(array("../js/bootstrap-filestyle.min.js","../js/custom.js"));
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('input').iCheck({
|
||||
checkboxClass: 'icheckbox_square-blue',
|
||||
increaseArea: '30%'
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user