Beispiel #1
0
    $sql = "UPDATE questionnaire_sample_quota_row\r\n\t\tSET autoprioritise = 0\r\n\t\tWHERE questionnaire_id = '{$questionnaire_id}'";
    $db->Execute($sql);
    foreach ($_POST as $key => $val) {
        $qsqr = bigintval(substr($key, 1));
        if (substr($key, 0, 1) == 'a') {
            $sql = "UPDATE questionnaire_sample_quota_row\r\n\t\t\t\tSET autoprioritise = 1\r\n\t\t\t\tWHERE questionnaire_sample_quota_row_id = {$qsqr}";
            $db->Execute($sql);
        } else {
            if (substr($key, 0, 1) == 'p') {
                $val = intval($val);
                $sql = "UPDATE questionnaire_sample_quota_row\r\n\t\t\t\tSET priority = '{$val}'\r\n\t\t\t\tWHERE questionnaire_sample_quota_row_id = {$qsqr}";
                $db->Execute($sql);
            }
        }
    }
    update_quota_priorities($questionnaire_id);
    $db->CompleteTrans();
}
xhtml_head(T_("Quota report"), true, array("../include/bootstrap/css/bootstrap.min.css", "../include/font-awesome/css/font-awesome.css", "../include/iCheck/skins/square/blue.css", "../css/custom.css"), array("../include/jquery/jquery.min.js", "../include/bootstrap/js/bootstrap.min.js", "../include/iCheck/icheck.min.js", "../js/window.js"));
print "<h3 class='form-inline pull-left'>" . T_("Select a questionnaire") . ":&emsp;</h3>";
$questionnaire_id = false;
if (isset($_GET['questionnaire_id'])) {
    $questionnaire_id = bigintval($_GET['questionnaire_id']);
}
display_questionnaire_chooser($questionnaire_id, false, "form-inline form-group", "form-control");
if ($questionnaire_id) {
    print "<h3 class='form-inline pull-left'>" . T_("Select a sample") . ":&emsp;</h3>";
    $sample_import_id = false;
    if (isset($_GET['sample_import_id'])) {
        $sample_import_id = bigintval($_GET['sample_import_id']);
    }
Beispiel #2
0
/**
 * Update the row quota table
 *
 * @param int $questionnaire_id The questionnaire ID to update
 * @param int|bool $case_id The case id if known to limit the scope of the search
 */
function update_row_quota($questionnaire_id, $case_id = false)
{
    global $db;
    $update = false;
    //whether to update priorities (only if changed)
    $db->StartTrans();
    $sql = "SELECT qsq.questionnaire_sample_quota_row_id\r\n\t\tFROM questionnaire_sample_quota_row as qsq\r\n\t\tWHERE qsq.questionnaire_id = '{$questionnaire_id}'\r\n    AND qsq.quota_reached != '1'\r\n    GROUP BY qsq.questionnaire_sample_quota_row_id";
    $rs = $db->GetAll($sql);
    if (isset($rs) && !empty($rs)) {
        foreach ($rs as $r) {
            $tmp = update_single_row_quota($r['questionnaire_sample_quota_row_id'], $case_id);
            if ($tmp) {
                $update = true;
            }
        }
    }
    if ($update) {
        update_quota_priorities($questionnaire_id);
    }
    $db->CompleteTrans();
    return false;
}