* Database file */ include "db.inc.php"; /** * Authentication */ require "auth-interviewer.php"; /** * XHTML functions */ include "functions/functions.xhtml.php"; /** * Operator functions */ include "functions/functions.operator.php"; $operator_id = get_operator_id(); $state = is_on_call($operator_id); $js = array("js/popup.js"); if (browser_ie()) { $js[] = "js/window_ie6_interface2.js"; } else { $js[] = "js/window_interface2.js"; } if (AUTO_LOGOUT_MINUTES !== false) { $js[] = "include/jquery/jquery-1.4.2.min.js"; $js[] = "js/childnap.js"; } xhtml_head(T_("Status"), false, array("include/bootstrap/css/bootstrap.min.css", "css/status_interface2.css"), $js); $ca = get_call_attempt($operator_id, false); if ($ca) { $respondent_id = get_respondent_id($ca);
<i class="fa fa-user-secret fa-lg fa-fw "></i><?php print T_("Client panel"); ?> </a> </li> <li class="dropdown pull-right user-data"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" style=" min-width: 160px;"> <i class="fa fa-user fa-fw "></i><?php print T_("Logged as:") . " " . $username; ?> </a> <!--- User menu // not connected to pages so not working yet // could be hidden --> <ul class="dropdown-menu" role="menu"> <li><a href="?g=5&page=operatorlist.php?edit=<?php print get_operator_id(); ?> "><i class="fa fa-cogs fa-fw "></i> <?php print T_("Settings"); ?> </a></li> <!--- <li><a href="../screenloc.php"><i class="fa fa-lock fa-fw "></i> <?php print T_("Lock Screen"); ?> </a></li> --> <li><a href="../include/limesurvey/admin/admin.php?action=logout"><i class="fa fa-sign-out fa-fw "></i> <?php print T_("Logout"); ?> </a></li> </ul> </li>
/** * Display appropriate outcomes based on current call attempt status * * @param int $contacted 0 for not contacted, 1 for contacted (a person on the phone) * @param int $ca Call attempt id * @param int $case_id The Case id * */ function display_outcomes($contacted, $ca, $case_id) { global $db; $completed = limesurvey_is_completed($case_id); //see if the case is completed if ($completed) { $sql = "SELECT outcome_id,description,contacted\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 10"; } else { if (limesurvey_is_quota_full($case_id)) { $sql = "SELECT outcome_id,description,contacted\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 32"; } else { //see if we have made an appointment on this call attempt $sql = "SELECT appointment_id\r\n\t\t\tFROM appointment\r\n\t\t\tWHERE completed_call_id IS NULL\r\n\t\t\tAND call_attempt_id = '{$ca}'"; $rs = $db->GetAll($sql); $outcomes = $db->GetOne("SELECT q.outcomes FROM `questionnaire` as q JOIN `case` as c ON (c.questionnaire_id =q.questionnaire_id) WHERE c.case_id = {$case_id}"); if (!empty($rs)) { //we have an appointment made ... only select appointment ID's $sql = "SELECT outcome_id,description,contacted\r\n\t\t\t\tFROM outcome\r\n\t\t\t\tWHERE outcome_type_id = '5'\r\n\t\t\t\tAND outcome_id IN ({$outcomes})"; } else { if ($contacted) { $contacted = bigintval($contacted); } else { print "<div class=\"form-group\" ><a href=\"?contacted=1\" class=\"btn btn-info\" style=\"margin-left: 15px; margin-right: 30px; min-width: 150px;\">" . T_("CONTACTED") . "</a>"; print "<a href=\"?contacted=0\" class=\"btn btn-default\" style=\"margin-left: 30px; margin-right: 15px; min-width: 150px;\">" . T_("NOT CONTACTED") . "</a></div>"; if (isset($_GET['contacted'])) { $contacted = bigintval($_GET['contacted']); } } if ($contacted == 1 || $contacted === 0) { $sql = "SELECT outcome_id,description,contacted\r\n\t\t\t\t\tFROM outcome\r\n\t\t\t\t\tWHERE outcome_type_id != '5'\r\n\t\t\t\t\tAND contacted = '{$contacted}'\r\n\t\t\t\t\tAND outcome_id IN ({$outcomes})\r\n\t\t\t\t\tAND outcome_id NOT IN(10,32,42,43,44,45)"; //don't show completed if not, Lime_Quota_full if not, hide max calls as they supposed to be automatic or admin-privileged } } } } $rs = $db->GetAll($sql); print "<div class=\"panel-body\">"; if (!empty($rs)) { $do = false; $lime_sid = get_limesurvey_id(get_operator_id()); //Check to see if we have sent an email on this call and set the default outcome $sql = "SELECT 41\r\n\t\t\tFROM `case` as c, " . LIME_PREFIX . "tokens_{$lime_sid} as t\r\n\t\t\tWHERE t.sent = '{$ca}'\r\n\t\t\tAND c.case_id = {$case_id}\r\n\t\t\tAND t.token = c.token"; $do = $db->GetOne($sql); if (isset($_GET['defaultoutcome'])) { $do = bigintval($_GET['defaultoutcome']); } foreach ($rs as $r) { if ($do == $r['outcome_id']) { $selected = "checked='checked'"; } else { $selected = ""; } if (isset($r['contacted']) && $r['contacted'] == 1) { $highlight = ""; } else { $highlight = "style='color:black;'"; } print "<div><a><label {$highlight} class='btn-link'><input type='radio' class='radio' name='outcome' id='outcome-{$r['outcome_id']}' value='{$r['outcome_id']}' {$selected} style='float:left'/> " . T_($r['description']) . "</label></a></div>"; } $_POST['confirm'] = true; //check that outcome selected } print "</div>"; }
/** * Retrieves the token attribute value from the related token table * * @param mixed $surveyid The survey ID * @param mixed $attrName The token-attribute field name * @param mixed $token The token code * @return string The token attribute value (or null on error) */ function GetAttributeValue($surveyid, $attrName, $token) { global $dbprefix, $connect; $attrName = strtolower($attrName); if ($attrName == 'callattempts' || $attrName == 'onappointment' || $attrName == 'perccomplete' || $attrName == 'messagesleft') { include_once "quexs.php"; $quexs_operator_id = get_operator_id(); $quexs_case_id = get_case_id($quexs_operator_id); if ($quexs_case_id) { if ($attrName == 'callattempts') { return get_call_attempts($quexs_case_id); } else { if ($attrName == 'onappointment') { return is_on_appointment($quexs_case_id, $quexs_operator_id); } else { if ($attrName == 'perccomplete') { return get_percent_complete($quexs_case_id); } else { if ($attrName == 'messagesleft') { return get_messages_left($quexs_case_id); } } } } } else { return 0; } } else { if (!tableExists('tokens_' . $surveyid) || !in_array($attrName, GetTokenConditionsFieldNames($surveyid))) { return null; } } $sanitized_token = $connect->qstr($token, get_magic_quotes_gpc()); $surveyid = sanitize_int($surveyid); $query = "SELECT {$attrName} FROM {$dbprefix}tokens_{$surveyid} WHERE token={$sanitized_token}"; $result = db_execute_num($query); $count = $result->RecordCount(); if ($count != 1) { return null; } else { $row = $result->FetchRow(); return $row[0]; } }
/** * Display appropriate outcomes based on current call attempt status * * @param int $contacted 0 for not contacted, 1 for contacted (a person on the phone) * @param int $ca Call attempt id * @param int $case_id The Case id * */ function display_outcomes($contacted, $ca, $case_id) { global $db; $completed = limesurvey_is_completed($case_id); //see if the case is completed if ($completed) { $sql = "SELECT outcome_id,description\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 10"; } else { if (limesurvey_is_quota_full($case_id)) { $sql = "SELECT outcome_id,description\r\n\t\t\tFROM outcome\r\n\t\t\tWHERE outcome_id = 32"; } else { //see if we have made an appointment on this call attempt $sql = "SELECT appointment_id\r\n\t\t\tFROM appointment\r\n\t\t\tWHERE completed_call_id IS NULL\r\n\t\t\tAND call_attempt_id = '{$ca}'"; $rs = $db->GetAll($sql); $outcomes = $db->GetOne("SELECT q.outcomes FROM `questionnaire` as q JOIN `case` as c ON (c.questionnaire_id =q.questionnaire_id) WHERE c.case_id = {$case_id}"); if (!empty($rs)) { //we have an appointment made ... only select appointment ID's $sql = "SELECT outcome_id,description\r\n\t\t\t\tFROM outcome\r\n\t\t\t\tWHERE outcome_type_id = '5'\r\n\t\t\t\tAND outcome_id IN ({$outcomes})"; } else { if ($contacted === false) { $ctd = ""; } else { $contacted = bigintval($contacted); $ctd = "AND contacted = '{$contacted}'"; } $sql = "SELECT outcome_id,description\r\n\t\t\t\t\tFROM outcome\r\n\t\t\t\t\tWHERE outcome_type_id != '5'\r\n\t\t\t\t\t{$ctd}\r\n\t\t\t\t\tAND outcome_id IN ({$outcomes})\r\n\t\t\t\t\tAND outcome_id NOT IN(10,32,42,43,44,45)"; //don't show completed if not, Lime_Quota_full if not, hide max calls as they supposed to be automatic or admin-privileged } } } $rs = $db->GetAll($sql); print "<div>"; if (!empty($rs)) { $lime_sid = get_limesurvey_id(get_operator_id()); //Check to see if we have sent an email on this call and set the default outcome $sql = "SELECT 41\r\n\t\t\tFROM `case` as c, " . LIME_PREFIX . "tokens_{$lime_sid} as t\r\n\t\t\tWHERE t.sent = '{$ca}'\r\n\t\t\tAND c.case_id = {$case_id}\r\n\t\t\tAND t.token = c.token"; $do = $db->GetOne($sql); if (isset($_GET['defaultoutcome'])) { $do = bigintval($_GET['defaultoutcome']); } foreach ($rs as $r) { if ($do == $r['outcome_id']) { $selected = "checked='checked'"; } else { $selected = ""; } print "<div><label class='label'><input type='radio' class='radio' name='outcome' id='outcome-{$r['outcome_id']}' value='{$r['outcome_id']}' {$selected}/>" . T_($r['description']) . "</label></div>"; } } print "</div>"; }
* Display functions */ include "../functions/functions.display.php"; /** * Performance functions */ include "../functions/functions.performance.php"; /** * Operator functions */ include "../functions/functions.operator.php"; /** * Input functions */ include "../functions/functions.input.php"; $admin_operator_id = get_operator_id(); $questionnaire_id = false; if (isset($_GET['questionnaire_id'])) { $questionnaire_id = bigintval($_GET['questionnaire_id']); } $css = array("../include/bootstrap/css/bootstrap.min.css", "../include/bootstrap/css/bootstrap-theme.min.css", "../include/font-awesome/css/font-awesome.css", "../css/custom.css"); $js_head = array("../include/jquery/jquery.min.js", "../include/bootstrap/js/bootstrap.min.js"); $js_foot = array("../js/window.js", "../js/custom.js"); xhtml_head(T_("Questionnaire Outcomes"), true, $css, $js_head); print "<h3 class='col-sm-4 pull-left text-right'>" . T_("Select a questionnaire") . "</h3>"; display_questionnaire_chooser($questionnaire_id, false, "pull-left col-sm-4", "form-control"); print "<div class='clearfix form-group'></div>"; if ($questionnaire_id != false) { //print "<h1>" . T_("Outcomes") . "</h1>"; print "<div class='col-sm-4'><div class='panel panel-body'><h5>" . T_("Sample status") . "</h5>"; $sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . TQ_("Drawn from sample") . "' ELSE '" . TQ_("Remain in sample") . "' END as drawn,\r\n\t\t\tcount(*) as count\r\n\t\tFROM sample as s\r\n\t\tJOIN questionnaire_sample as qs ON (qs.questionnaire_id = '{$questionnaire_id}' and qs.sample_import_id = s.import_id)\r\n\t\tLEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)\r\n\t\tGROUP BY (c.sample_id is not null)";
/** * Get start interviewer URL * * @return string The URL to start the interview */ function get_start_interview_url() { $db = newADOConnection(DB_TYPE); $db->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); $db->SetFetchMode(ADODB_FETCH_ASSOC); $operator_id = get_operator_id(); $url = QUEXS_URL . "nocaseavailable.php"; $case_id = get_case_id($operator_id); if ($case_id) { $sql = "SELECT token\r\n\t\t\tFROM `case`\r\n\t\t\tWHERE case_id = {$case_id}"; $token = $db->GetOne($sql); $sid = get_limesurvey_id($operator_id); $url = LIME_URL . "index.php?interviewer=interviewer&loadall=reload&sid={$sid}&token={$token}&lang=" . DEFAULT_LOCALE; $questionnaire_id = get_questionnaire_id($operator_id); //get prefills $sql = "SELECT lime_sgqa,value\r\n FROM questionnaire_prefill\r\n WHERE questionnaire_id = '{$questionnaire_id}'"; $pf = $db->GetAll($sql); if (!empty($pf)) { foreach ($pf as $p) { $url .= "&" . $p['lime_sgqa'] . "=" . quexs_template_replace($p['value']); } } } return $url; }
*/ include "functions/functions.xhtml.php"; /** * Operator functions */ include "functions/functions.operator.php"; $js = false; if (AUTO_LOGOUT_MINUTES !== false) { $js = array("include/jquery/jquery-1.4.2.min.js", "js/childnap.js"); } xhtml_head(T_("Call List"), false, array("css/table.css"), $js, false, 60); //List the case call history // display in respondent time so that the operator will be able to // quote verbatim to the respondent if necessary $db->StartTrans(); $case_id = get_case_id(get_operator_id()); if ($case_id) { global $db; $sql = "SELECT DATE_FORMAT(CONVERT_TZ(c.start,'UTC',r.Time_zone_name),'" . DATE_TIME_FORMAT . "') as start,CONVERT_TZ(c.end,'UTC',r.Time_zone_name) as end, op.firstName, op.lastName, o.description as des, cp.phone as cphone\r\n\t\tFROM `call` as c\r\n\t\tJOIN (operator as op, outcome as o, respondent as r, contact_phone as cp) on (c.operator_id = op.operator_id and c.outcome_id = o.outcome_id and r.respondent_id = c.respondent_id and c.contact_phone_id = cp.contact_phone_id)\r\n\t\tWHERE c.case_id = '{$case_id}'\r\n\t\tORDER BY c.start DESC"; $rs = $db->GetAll($sql); if (empty($rs)) { print "<p>" . T_("No calls made") . "</p>"; } else { translate_array($rs, array("des")); xhtml_table($rs, array("start", "des", "cphone", "firstName"), array(T_("Date/Time"), T_("Outcome"), T_("Number called"), T_("Operator"))); } } else { print "<p>" . T_("No case") . "</p>"; } xhtml_foot(); $db->CompleteTrans();
function do_multipleshorttext($ia) { global $dbprefix, $clang, $thissurvey; $answer = ''; $qidattributes = getQuestionAttributes($ia[0], $ia[4]); if ($qidattributes['numbers_only'] == 1) { $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; $checkconditionFunction = "fixnum_checkconditions"; } else { $checkconditionFunction = "checkconditions"; } if (intval(trim($qidattributes['maximum_chars'])) > 0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars = intval(trim($qidattributes['maximum_chars'])); $maxlength = "maxlength='{$maximum_chars}' "; } else { $maxlength = ""; } if (trim($qidattributes['text_input_width']) != '') { $tiwidth = $qidattributes['text_input_width']; } else { $tiwidth = 20; } if (trim($qidattributes['prefix']) != '') { $prefix = $qidattributes['prefix']; } else { $prefix = ''; } if (trim($qidattributes['suffix']) != '') { $suffix = $qidattributes['suffix']; } else { $suffix = ''; } if ($thissurvey['nokeyboard'] == 'Y') { vIncludeKeypad(); $kpclass = "text-keypad"; } else { $kpclass = ""; } if ($qidattributes['random_order'] == 1) { $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['s_lang'] . "' ORDER BY " . db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia['0']} AND language='" . $_SESSION['s_lang'] . "' ORDER BY question_order"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount() * 2; //$answer .= "\t<input type='hidden' name='MULTI$ia[1]' value='$anscount'>\n"; $fn = 1; $answer_main = ''; $label_width = 0; if ($anscount == 0) { $inputnames = array(); $answer_main .= ' <li>' . $clang->gT('Error: This question has no answers.') . "</li>\n"; } else { if (trim($qidattributes['display_rows']) != '') { //question attribute "display_rows" is set -> we need a textarea to be able to show several rows $drows = $qidattributes['display_rows']; while ($ansrow = $ansresult->FetchRow()) { $myfname = $ia[1] . $ansrow['title']; if ($ansrow['question'] == "") { $ansrow['question'] = " "; } $quexs_answer = false; if (strncasecmp($ansrow['question'], "{SAMPLEUPDATE:", 14) == 0) { $ansrow['question'] = substr($ansrow['question'], 14, -1); //remove token text include_once 'quexs.php'; $quexs_operator_id = get_operator_id(); $quexs_case_id = get_case_id($quexs_operator_id); if ($quexs_case_id) { $quexs_answer = get_sample_variable($ansrow['question'], $quexs_case_id); $tiwidth = strlen($quexs_answer) + 5; $maxsize = $tiwidth + 255; } } list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li"); $answer_main .= "\t{$htmltbody2}\n" . "<label for=\"answer{$myfname}\">{$ansrow['question']}</label>\n" . "\t<span>\n" . $prefix . "\n" . ' <textarea class="textarea ' . $kpclass . '" name="' . $myfname . '" id="answer' . $myfname . '" rows="' . $drows . '" cols="' . $tiwidth . '" ' . $maxlength . ' onkeyup="' . $checkconditionFunction . '(this.value, this.name, this.type);" >'; if ($label_width < strlen(trim(strip_tags($ansrow['question'])))) { $label_width = strlen(trim(strip_tags($ansrow['question']))); } if ($quexs_answer !== false) { $answer_main .= $quexs_answer; } else { if (isset($_SESSION[$myfname])) { $dispVal = $_SESSION[$myfname]; if ($qidattributes['numbers_only'] == 1) { $dispVal = str_replace('.', $sSeperator, $dispVal); } $answer_main .= htmlspecialchars(htmlspecialchars($dispVal)); } } $answer_main .= "</textarea>\n" . $suffix . "\n\t</span>\n" . "\t</li>\n"; $fn++; $inputnames[] = $myfname; } } else { while ($ansrow = $ansresult->FetchRow()) { $myfname = $ia[1] . $ansrow['title']; if ($ansrow['question'] == "") { $ansrow['question'] = " "; } $quexs_answer = false; if (strncasecmp($ansrow['question'], "{SAMPLEUPDATE:", 14) == 0) { $ansrow['question'] = substr($ansrow['question'], 14, -1); //remove token text include_once 'quexs.php'; $quexs_operator_id = get_operator_id(); $quexs_case_id = get_case_id($quexs_operator_id); if ($quexs_case_id) { $quexs_answer = get_sample_variable($ansrow['question'], $quexs_case_id); $tiwidth = strlen($quexs_answer) + 5; $maxsize = $tiwidth + 255; } } list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li"); // color code missing mandatory questions red if ($ia[6] == 'Y' && ($_SESSION['step'] == $_SESSION['prevstep'] || $_SESSION['maxstep'] > $_SESSION['step']) && $_SESSION[$myfname] == '') { $ansrow['question'] = "<span class='errormandatory'>{$ansrow['question']}</span>"; } $answer_main .= "\t{$htmltbody2}\n" . "<label for=\"answer{$myfname}\">{$ansrow['question']}</label>\n" . "\t<span>\n" . $prefix . "\n" . '<input class="text ' . $kpclass . '" type="text" size="' . $tiwidth . '" name="' . $myfname . '" id="answer' . $myfname . '" value="'; if ($label_width < strlen(trim(strip_tags($ansrow['question'])))) { $label_width = strlen(trim(strip_tags($ansrow['question']))); } if ($quexs_answer !== false) { $answer_main .= $quexs_answer; } else { if (isset($_SESSION[$myfname])) { $dispVal = $_SESSION[$myfname]; if ($qidattributes['numbers_only'] == 1) { $dispVal = str_replace('.', $sSeperator, $dispVal); } $answer_main .= htmlspecialchars($dispVal, ENT_QUOTES, 'UTF-8'); } } $answer_main .= '" onkeyup="' . $checkconditionFunction . '(this.value, this.name, this.type);" ' . $maxlength . ' />' . "\n" . $suffix . "\n\t</span>\n" . "\t</li>\n"; $fn++; $inputnames[] = $myfname; } } } $answer = "<ul>\n" . $answer_main . "</ul>\n"; return array($answer, $inputnames); }
/** * check_quota() returns quota information for the current survey * @param string $checkaction - action the function must take after completing: * enforce: Enforce the Quota action * return: Return the updated quota array from getQuotaAnswers() * @param string $surveyid - Survey identification number * @return array - nested array, Quotas->Members->Fields, includes quota status and which members matched in session. */ function check_quota($checkaction, $surveyid) { if (!isset($_SESSION['s_lang'])) { return; } global $thistpl, $clang, $clienttoken, $publicurl; $global_matched = false; $quota_info = getQuotaInformation($surveyid, $_SESSION['s_lang']); $x = 0; if (count($quota_info) > 0) { // Check each quota on saved data to see if it is full $querycond = array(); foreach ($quota_info as $quota) { if (count($quota['members']) > 0) { $fields_list = array(); // Keep a list of fields for easy reference $y = 0; // We need to make the conditions for the select statement here unset($querycond); // fill the array of value and query for each fieldnames $fields_value_array = array(); $fields_query_array = array(); foreach ($quota['members'] as $member) { foreach ($member['fieldnames'] as $fieldname) { if (!in_array($fieldname, $fields_list)) { $fields_list[] = $fieldname; $fields_value_array[$fieldname] = array(); $fields_query_array[$fieldname] = array(); } $fields_value_array[$fieldname][] = $member['value']; $fields_query_array[$fieldname][] = "s." . db_quote_id($fieldname) . " = '{$member['value']}'"; } } // fill the $querycond array with each fields_query grouped by fieldname foreach ($fields_list as $fieldname) { $select_query = " ( " . implode(' OR ', $fields_query_array[$fieldname]) . ' )'; $querycond[] = $select_query; } // Test if the fieldname is in the array of value in the session foreach ($quota['members'] as $member) { foreach ($member['fieldnames'] as $fieldname) { if (isset($_SESSION[$fieldname])) { if (in_array($_SESSION[$fieldname], $fields_value_array[$fieldname])) { $quota_info[$x]['members'][$y]['insession'] = "true"; } } } $y++; } unset($fields_query_array); unset($fields_value_array); // Lets only continue if any of the quota fields is in the posted page $matched_fields = false; if (isset($_POST['fieldnames'])) { $posted_fields = explode("|", $_POST['fieldnames']); foreach ($fields_list as $checkfield) { if (in_array($checkfield, $posted_fields)) { $matched_fields = true; $global_matched = true; } } } // A field was submitted that is part of the quota if ($matched_fields == true) { //queXS Addition include_once 'quexs.php'; $case_id = get_case_id(get_operator_id()); // Check the status of the quota, is it full or not $querysel = "SELECT id FROM " . db_table_name('survey_' . $surveyid) . " AS s\n\t\t\t\t JOIN `case` AS cq ON (cq.case_id = '{$case_id}')\n\t\t\t\t JOIN sample AS sampt ON (sampt.sample_id = cq.sample_id)\n\t\t\t\t JOIN `case` AS c ON (c.token = s.token AND c.questionnaire_id = cq.questionnaire_id)\n\t\t\t\t JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = sampt.import_id)\n\t\t\t WHERE " . implode(' AND ', $querycond) . " " . " \n\t\t\t\t\tAND s.submitdate IS NOT NULL"; $result = db_execute_assoc($querysel) or safe_die($connect->ErrorMsg()); //Checked $quota_check = $result->FetchRow(); if ($result->RecordCount() >= $quota['Limit']) { // Now we have to check if the quota matches in the current session // This will let us know if this person is going to exceed the quota $counted_matches = 0; foreach ($quota_info[$x]['members'] as $member) { if (isset($member['insession']) && $member['insession'] == "true") { $counted_matches++; } } if ($counted_matches == count($quota['members'])) { // They are going to exceed the quota if data is submitted $quota_info[$x]['status'] = "matched"; } else { $quota_info[$x]['status'] = "notmatched"; } } else { // Quota is no in danger of being exceeded. $quota_info[$x]['status'] = "notmatched"; } } } $x++; } } else { return false; } // Now we have all the information we need about the quotas and their status. // Lets see what we should do now if ($checkaction == 'return') { return $quota_info; } else { if ($global_matched == true && $checkaction == 'enforce') { // Need to add Quota action enforcement here. reset($quota_info); $tempmsg = ""; $found = false; foreach ($quota_info as $quota) { if (isset($quota['status']) && $quota['status'] == "matched" && (isset($quota['Action']) && $quota['Action'] == "1")) { // If a token is used then mark the token as completed if (isset($clienttoken) && $clienttoken) { submittokens(true); } session_destroy(); sendcacheheaders(); if ($quota['AutoloadUrl'] == 1 && $quota['Url'] != "") { header("Location: " . $quota['Url'] . "?message=" . $quota['Message']); } doHeader(); echo templatereplace(file_get_contents("{$thistpl}/startpage.pstpl")); echo "\t<div class='quotamessage'>\n"; echo "\t" . $quota['Message'] . "<br /><br />\n"; echo "\t<a href='" . $quota['Url'] . "'>" . $quota['UrlDescrip'] . "</a><br />\n"; echo "\t</div>\n"; echo templatereplace(file_get_contents("{$thistpl}/endpage.pstpl")); doFooter(); exit; } if (isset($quota['status']) && $quota['status'] == "matched" && (isset($quota['Action']) && $quota['Action'] == "2")) { sendcacheheaders(); doHeader(); echo templatereplace(file_get_contents("{$thistpl}/startpage.pstpl")); echo "\t<div class='quotamessage'>\n"; echo "\t" . $quota['Message'] . "<br /><br />\n"; echo "\t<a href='" . $quota['Url'] . "'>" . $quota['UrlDescrip'] . "</a><br />\n"; echo "<form method='post' action='{$publicurl}/index.php' id='limesurvey' name='limesurvey'><input type=\"hidden\" name=\"move\" value=\"movenext\" id=\"movenext\" /><input class='submit' accesskey='p' type='button' onclick=\"javascript:document.limesurvey.move.value = 'moveprev'; document.limesurvey.submit();\" value=' << " . $clang->gT("Previous") . " ' name='move2' />\n <input type='hidden' name='thisstep' value='" . $_SESSION['step'] . "' id='thisstep' />\n <input type='hidden' name='sid' value='" . returnglobal('sid') . "' id='sid' />\n <input type='hidden' name='token' value='" . $clienttoken . "' id='token' />\n </form>\n"; echo "\t</div>\n"; echo templatereplace(file_get_contents("{$thistpl}/endpage.pstpl")); doFooter(); exit; } } } else { // Unknown value return false; } } }