$sgqa = $db->qstr($data[$i * 3]); $sql = "INSERT INTO qsqr_question (questionnaire_sample_quota_row_id,lime_sgqa,value,comparison)\r\n VALUES ({$qq},{$sgqa},{$value},{$comparison})"; $db->Execute($sql); } else { //is a sample variable $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_id,exclude_var,exclude_val,comparison)\r\n VALUES ({$qq},{$var_id},{$var},{$value},{$comparison})"; $db->Execute($sql); } } } //Make sure to calculate on the spot update_single_row_quota($qq); } } fclose($handle); } } if ($qsqri != false) { print "<div class='col-lg-2 pull-right'><a href='?questionnaire_id={$questionnaire_id}&sample_import_id={$sample_import_id}' class='btn btn-default'><i class='fa fa-arrow-up fa-lg text-primary'></i> " . T_("To Row quotas") . "</a></div>"; print "<div class='clearfix form-group'></div>"; print "<h2 class='col-lg-offset-4'>" . T_("Quota") . ": {$qsqrid}</h2>"; ?> <div class='panel-body' > <form action="?<?php echo "questionnaire_id={$questionnaire_id}&sample_import_id={$sample_import_id}"; ?> " method="post" class="form-inline table">
/** * 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; }