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

merge fixes from fixies

This commit is contained in:
Alex
2015-12-21 20:42:48 +03:00
4 changed files with 37 additions and 33 deletions

View File

@@ -85,19 +85,19 @@ if (isset($_GET['key']) || isset($_GET['sample']))
echo("token,".T_("Case ID").""); echo("token,".T_("Case ID")."");
foreach($svars as $s) foreach($svars as $s)
{ {
echo("," . $s['value']); echo("," . str_replace(","," ",$s['value']));
} }
if (isset($_GET['sample'])) if (isset($_GET['sample']))
{ {
echo(",".T_("Current Outcome").",".T_("Number of call attempts").",".T_("Number of calls").",".T_("Case notes").",".T_("Total interview time over all calls (mins)").",".T_("Interview time for last call (mins)").",".T_("Last number dialled").",".T_("DATE/TIME Last number dialled").",".T_("Operator username for last call").",".T_("Shift report").", AAPOR"); echo(",".T_("Outcome ID").",".T_("Current Outcome").",".T_("Number of call attempts").",".T_("Number of calls").",".T_("Case notes").",".T_("Total interview time over all calls (mins)").",".T_("Interview time for last call (mins)").",".T_("Last number dialled").",".T_("DATE/TIME Last number dialled").",".T_("Operator username for last call").",".T_("Shift report").", AAPOR");
} }
echo("\n"); echo("\n");
$sql = "SELECT c.token,c.case_id "; $sql = "SELECT c.token,c.case_id ";
if (isset($_GET['sample'])) $sql .= ", o.description, if (isset($_GET['sample'])) $sql .= ", o.outcome_id, o.description,
(SELECT COUNT(ca.call_attempt_id) FROM `call_attempt` as ca WHERE ca.case_id = c.case_id ) as callattempts, (SELECT COUNT(ca.call_attempt_id) FROM `call_attempt` as ca WHERE ca.case_id = c.case_id ) as callattempts,
(SELECT COUNT(cl.call_id) FROM `call` as cl WHERE cl.case_id = c.case_id ) as calls, (SELECT COUNT(cl.call_id) FROM `call` as cl WHERE cl.case_id = c.case_id ) as calls,
(SELECT GROUP_CONCAT(cn1.note SEPARATOR '|') FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes, (SELECT GROUP_CONCAT(cn1.note SEPARATOR '|') FROM `case_note` as cn1 WHERE c.case_id = cn1.case_id GROUP BY cn1.case_id)as casenotes,
@@ -149,8 +149,8 @@ if (isset($_GET['key']) || isset($_GET['sample']))
} }
if (isset($_GET['sample'])) if (isset($_GET['sample']))
{ {
$l['description'] = T_($l['description']); if(!empty($l['description'])) $l['description'] = T_($l['description']);
echo "," . str_replace(","," ",$l['description']) . "," .$l['callattempts']."," .$l['calls']."," .$l['casenotes'].",".$l['interviewtimec'].",".$l['interviewtimel'].",".$l['lastnumber'].",".$l['lastcallstart'].",".$l['operatoru'].",".$l['shiftr'].",". $l['aapor_id']; echo ",".$l['outcome_id'].",". str_replace(","," ",$l['description']).",".$l['callattempts'].",".$l['calls']."," .str_replace(","," ",$l['casenotes']).",".$l['interviewtimec'].",".$l['interviewtimel'].",".$l['lastnumber'].",".$l['lastcallstart'].",".$l['operatoru'].",".$l['shiftr'].",". $l['aapor_id'];
} }
echo "\n"; echo "\n";
} }

View File

@@ -89,13 +89,9 @@ if (isset($_POST['ed']))
unset($_POST['ed']); unset($_POST['ed']);
unset($_POST['sample_import_id']); unset($_POST['sample_import_id']);
// print_r($_POST). "</br>"; //ïîñìîòðèì ÷åãî îòðàâëÿåòñÿ
if (isset($_POST['del']) && isset($_POST['type']) ) { if (isset($_POST['del']) && isset($_POST['type']) ) {
$a = array(); $b = array(); $cert = array(); $a = $_POST['type']; $a = array(); $b = array(); $cert = array(); $a = $_POST['type'];
//echo "<p> type before unset->>"; foreach($_POST['type'] as $key => $val) { echo ' | ', $key,' => ',$val,' | '; }; print "</p>";
foreach($_POST['del'] as $p) { foreach($_POST['del'] as $p) {
unset ($_POST['type'][$p]); unset ($_POST['type'][$p]);
@@ -110,7 +106,6 @@ if (isset($_POST['ed']))
} }
/* else { echo "<div class='alert alert-info'>", T_("You can delete string '$key'. "), "</div>"; } */ /* else { echo "<div class='alert alert-info'>", T_("You can delete string '$key'. "), "</div>"; } */
} }
//echo "<p>del ->>"; foreach($_POST['del'] as $key => $val) { echo ' | ', $key,' => ',$val,' | '; }; print "</p>";
} }
if (isset($_POST['type'])){ if (isset($_POST['type'])){
@@ -136,7 +131,7 @@ if (isset($_POST['ed']))
if ($eml < 2) {$ch4 = true;} if ($eml < 2) {$ch4 = true;}
else { echo "<div class='alert alert-warning'>", T_("Too many e-mail fields. Please check selected types for E-mail."), "</div>"; } else { echo "<div class='alert alert-warning'>", T_("Too many e-mail fields. Please check selected types for E-mail."), "</div>"; }
if ($ch1 && $ch2 && $ch3 && $ch4) */$typecheck = true; //echo $ch1,$ch2,$ch3,$ch4, "typecheck=",$typecheck, "</br>" ; if ($ch1 && $ch2 && $ch3 && $ch4) */$typecheck = true;
if ($typecheck){ if ($typecheck){
@@ -178,11 +173,10 @@ if (isset($_POST['ed']))
if (isset($_POST['var'])){ if (isset($_POST['var'])){
foreach($_POST['var'] as $p => $val) foreach($_POST['var'] as $p => $val)
{// echo '| ',$p,' => ',$val,'+ '; {
$v = str_replace(" ", "_", $val); $val = str_replace(array(" ,",", ",","," "," "),"_", $val);
$sql = "UPDATE sample_import_var_restrict $sql = "UPDATE sample_import_var_restrict
SET `var` = '$v' SET `var` = '$val'
WHERE sample_import_id = $sample_import_id WHERE sample_import_id = $sample_import_id
AND `var_id` = $p"; AND `var_id` = $p";
$db->Execute($sql); $db->Execute($sql);
@@ -199,7 +193,7 @@ if (isset($_POST['ed']))
$db->Execute($sql); $db->Execute($sql);
foreach($_POST['see'] as $p => $val) foreach($_POST['see'] as $p => $val)
{// echo $p,' => ',$val,' + '; {
$sql = "UPDATE sample_import_var_restrict $sql = "UPDATE sample_import_var_restrict
SET `restrict` = 0 SET `restrict` = 0
WHERE sample_import_id = $sample_import_id WHERE sample_import_id = $sample_import_id
@@ -300,7 +294,7 @@ if (isset($_GET['edit']) )
$rd = $db->GetAll($sql); $rd = $db->GetAll($sql);
$sql = "SELECT sir.var_id, $sql = "SELECT sir.var_id,
CONCAT('<input type=\"text\" onInput=\"$(this).attr(\'name\',\'var[',sir.var_id,']\');\" value=\"' ,sir.var, '\" required class=\"form-control\" style=\"min-width: 300px;\" $dis />') as var, CONCAT('<input type=\"text\" name=\"var[',sir.var_id,']\" value=\"' ,sir.var, '\" required class=\"form-control\" style=\"min-width: 300px;\" $dis />') as var,
CONCAT ('<select name=\"type[',sir.var_id,']\" class=\"form-control\" $dis >"; CONCAT ('<select name=\"type[',sir.var_id,']\" class=\"form-control\" $dis >";
foreach($rd as $r) foreach($rd as $r)
{ {
@@ -356,7 +350,7 @@ if ($rs){
<?php <?php
print "<div class='well text-danger col-sm-3'><p>" . T_("Select which fields from this sample to deidentify. </p> Deidentified fields will be permanently deleted from the sample.") . "</p></div>"; if($sd['enabled'] == 0) print "<div class='well text-danger col-sm-3'><p>" . T_("Select which fields from this sample to deidentify. </p> Deidentified fields will be permanently deleted from the sample.") . "</p></div>";
} }
else else
{ {
@@ -391,7 +385,6 @@ else
$rs = $db->GetAll($sql); $rs = $db->GetAll($sql);
if (!empty($rs)) { if (!empty($rs)) {
$count = count($rs); $count = count($rs);
//print_r($rs);
print "<div class='well text-danger col-sm-3'><p>" . T_("Fix this sample ") . "</p>"; print "<div class='well text-danger col-sm-3'><p>" . T_("Fix this sample ") . "</p>";
print "<p>" . $count . " var id's not match</p>"; print "<p>" . $count . " var id's not match</p>";

View File

@@ -136,7 +136,7 @@ function display_table($data)
foreach ($data as $key => $value) foreach ($data as $key => $value)
{ {
$val = str_replace(" ", "_", $value); $val = str_replace(array(" ,",", ",","," "," "),"_", $value);
$checked = "checked"; $checked = "checked";
if (empty($val)) $val = "samp_$row"; if (empty($val)) $val = "samp_$row";
@@ -219,19 +219,14 @@ function import_file($file, $description, $fields, $firstrow = 2)
if (strncmp($key, "i_", 2) == 0) if (strncmp($key, "i_", 2) == 0)
{ {
$selected_type[substr($key,2)] = $fields["t_" . substr($key,2)]; $selected_type[substr($key,2)] = $fields["t_" . substr($key,2)];
$selected_name[substr($key,2)] = $fields["n_" . substr($key,2)]; $selected_name[substr($key,2)] = str_replace(array(" ,",", ",","," "," "),"_", $fields["n_" . substr($key,2)]);
$restrict = 1;
//Set restrictions on columns //Set restrictions on columns
if (isset($fields["a_" . substr($key,2)])) if (isset($fields["a_" . substr($key,2)])) $restrict = 0; else $restrict = 1;
{
$restrict = 0;
}
$sql = "INSERT INTO sample_import_var_restrict $sql = "INSERT INTO sample_import_var_restrict
(`sample_import_id`,`var`,`type`,`restrict`) (`sample_import_id`,`var`,`type`,`restrict`)
VALUES ($id,'" . $fields["n_" . substr($key,2)] . "','" . $fields["t_" . substr($key,2)] . "',$restrict)"; VALUES ($id,'" . $selected_name[substr($key,2)] . "','" . $selected_type[substr($key,2)] . "',$restrict)";
$db->Execute($sql); $db->Execute($sql);

View File

@@ -256,6 +256,7 @@ $quexsfilterstate = questionnaireSampleFilterstate();
$exportoutput .= "<option value='token' id='token' />".T_("Token")."</option>\n" $exportoutput .= "<option value='token' id='token' />".T_("Token")."</option>\n"
."<option value='caseid' id='caseid' />".T_("Case ID")."</option>\n" ."<option value='caseid' id='caseid' />".T_("Case ID")."</option>\n"
."<option value='outcomeid' id='outcomeid' />".T_("Outcome ID")."</option>\n"
."<option value='caseoutcome' id='caseoutcome' />".T_("Case outcome")."</option>\n" ."<option value='caseoutcome' id='caseoutcome' />".T_("Case outcome")."</option>\n"
."<option value='callattempts' id='callattempts' />".T_("Number of call attempts")."</option>\n" ."<option value='callattempts' id='callattempts' />".T_("Number of call attempts")."</option>\n"
."<option value='messagesleft' id='messagesleft' />".T_("Number of answering machine messages left")."</option>\n" ."<option value='messagesleft' id='messagesleft' />".T_("Number of answering machine messages left")."</option>\n"
@@ -280,7 +281,7 @@ $quexsfilterstate = questionnaireSampleFilterstate();
foreach ($queXSrs as $attr_name=>$val) foreach ($queXSrs as $attr_name=>$val)
{ {
$exportoutput .= "<option value='SAMPLE:$attr_name' id='SAMPLE:$attr_name' />Sample: ".$attr_name."</option>\n"; $exportoutput .= "<option value='SAMPLE:$attr_name' id='SAMPLE:$attr_name' />SAMPLE: ".$attr_name."</option>\n";
} }
$exportoutput .= "</select></fieldset>\n"; $exportoutput .= "</select></fieldset>\n";
} }
@@ -435,6 +436,12 @@ if ($tokenTableExists && $thissurvey['anonymized']=='N' && isset($_POST['attribu
$dquery .= ", (SELECT c4.case_id $dquery .= ", (SELECT c4.case_id
FROM `case` as c4 FROM `case` as c4
WHERE c4.token = {$dbprefix}survey_$surveyid.token) as caseid "; WHERE c4.token = {$dbprefix}survey_$surveyid.token) as caseid ";
}
if (in_array('outcomeid',$_POST['attribute_select']))
{
$dquery .= ", (SELECT c5.current_outcome_id
FROM `case` as c5
WHERE c5.token = {$dbprefix}survey_$surveyid.token) as outcomeid ";
} }
if (in_array('caseoutcome',$_POST['attribute_select'])) if (in_array('caseoutcome',$_POST['attribute_select']))
{ {
@@ -643,11 +650,16 @@ for ($i=0; $i<$fieldcount; $i++)
{ {
if ($type == "csv") {$firstline .= "\"".T_("Case ID")."\"$separator";} if ($type == "csv") {$firstline .= "\"".T_("Case ID")."\"$separator";}
else {$firstline .= T_("Case ID")."$separator";} else {$firstline .= T_("Case ID")."$separator";}
}
elseif ($fieldinfo == "outcomeid")
{
if ($type == "csv") {$firstline .= "\"".T_("Outcome ID")."\"$separator";}
else {$firstline .= T_("Outcome ID")."$separator";}
} }
elseif ($fieldinfo == "caseoutcome") elseif ($fieldinfo == "caseoutcome")
{ {
if ($type == "csv") {$firstline .= "\"".T_("Case outcome")."\"$separator";} if ($type == "csv") {$firstline .= "\"".T_("Case outcome")."\"$separator";}
else {$firstline .= T_("Case outcome")."$separator";} else {$firstline .= T_("Case outcome")."$separator";} $caseoutcome_key = $i;
} }
elseif ($fieldinfo == "email") elseif ($fieldinfo == "email")
{ {
@@ -838,7 +850,7 @@ if ($answers == "short") //Nice and easy. Just dump the data straight
$rowcounter=0; $rowcounter=0;
while ($drow = $dresult->FetchRow()) while ($drow = $dresult->FetchRow())
{ {
$drow=array_map('strip_tags_full',$drow); if (isset($drow['caseoutcome'])) $drow['caseoutcome'] = T_($drow['caseoutcome']); $drow=array_map('strip_tags_full',$drow); if (isset($drow['caseoutcome']) && !empty($drow['caseoutcome'])) $drow['caseoutcome'] = T_($drow['caseoutcome']);
if($convertyto1 == "Y") if($convertyto1 == "Y")
//Converts "Y" to "1" in export //Converts "Y" to "1" in export
{ {
@@ -921,6 +933,7 @@ elseif ($answers == "long") //chose complete answers
while ($drow = $dresult->FetchRow()) while ($drow = $dresult->FetchRow())
{ {
if (isset($caseoutcome_key) && isset($drow[$caseoutcome_key]) && !empty($drow[$caseoutcome_key])) $drow[$caseoutcome_key] = T_($drow[$caseoutcome_key]);
$rowcounter++; $rowcounter++;
if ($type == "pdf") if ($type == "pdf")
{ {
@@ -942,7 +955,7 @@ elseif ($answers == "long") //chose complete answers
$fqid=0; // By default fqid is set to zero $fqid=0; // By default fqid is set to zero
$field=$dresult->FetchField($i); $field=$dresult->FetchField($i);
$fieldinfo=$field->name; $fieldinfo=$field->name;
if ($fieldinfo != "startlanguage" && $fieldinfo != "id" && $fieldinfo != "datestamp" && $fieldinfo != "startdate" && $fieldinfo != "ipaddr" && $fieldinfo != "refurl" && $fieldinfo != "token" && $fieldinfo != "firstname" && $fieldinfo != "lastname" && $fieldinfo != "email" && (substr($fieldinfo,0,10)!="attribute_") && $fieldinfo != "completed" && $fieldinfo != "caseoutcome"&& $fieldinfo != "caseid" && $fieldinfo != "callattempts" && $fieldinfo != "messagesleft"&& $fieldinfo != "casenotes"&& $fieldinfo != "interviewtimec"&& $fieldinfo != "interviewtimel"&& $fieldinfo != "lastnumber"&& $fieldinfo != "operatoru"&& $fieldinfo != "shiftr") if ($fieldinfo != "startlanguage" && $fieldinfo != "id" && $fieldinfo != "datestamp" && $fieldinfo != "startdate" && $fieldinfo != "ipaddr" && $fieldinfo != "refurl" && $fieldinfo != "token" && $fieldinfo != "firstname" && $fieldinfo != "lastname" && $fieldinfo != "email" && (substr($fieldinfo,0,10)!="attribute_") && $fieldinfo != "completed" && $fieldinfo != "outcomeid" && $fieldinfo != "caseoutcome"&& $fieldinfo != "caseid" && $fieldinfo != "callattempts" && $fieldinfo != "messagesleft"&& $fieldinfo != "casenotes"&& $fieldinfo != "interviewtimec"&& $fieldinfo != "interviewtimel"&& $fieldinfo != "lastnumber"&& $fieldinfo != "operatoru"&& $fieldinfo != "shiftr")
{ {
$fielddata=$fieldmap[$fieldinfo]; $fielddata=$fieldmap[$fieldinfo];
$fqid=$fielddata['qid']; $fqid=$fielddata['qid'];
@@ -966,7 +979,10 @@ elseif ($answers == "long") //chose complete answers
case "caseid": case "caseid":
$ftitle=T_("Case ID").":"; $ftitle=T_("Case ID").":";
break; break;
case "caseoutcome": case "outcomeid":
$ftitle=T_("Outcome ID").":";
break;
case "caseoutcome":
$ftitle=T_("Case outcome").":"; $ftitle=T_("Case outcome").":";
break; break;
case "callattempts": case "callattempts":