function disp_query($queryid = 0) { $qansdisp = ""; $detsql = "select distinct question_id from {{query_detail}} where query_id = '" . $queryid . "' order by question_id"; $qrydetail = Yii::app()->db->createCommand($detsql)->query()->readAll(); foreach ($qrydetail as $rs) { $sValue = "question_id_" . $rs['question_id']; $tValue = getQuestionText($rs['question_id']); $qID = $rs['question_id']; $aSql = "select * from {{profile_answer}} where question_id = '" . $qID . "'"; $adetail = Yii::app()->db->createCommand($aSql)->query()->readAll(); $anslist = ""; foreach ($adetail as $ars) { $isanssql = "select * from {{query_detail}} where query_id = '" . $queryid . "' and answer_id = '" . $ars['id'] . "' "; $isansdetail = Yii::app()->db->createCommand($isanssql)->query()->readAll(); if (count($isansdetail) > 0) { $anslist .= '<input type="checkbox" name="' . $sValue . '[]" value="' . $ars['id'] . '" checked> ' . $ars['title'] . '<br />'; } else { $anslist .= '<input type="checkbox" name="' . $sValue . '[]" value="' . $ars['id'] . '"> ' . $ars['title'] . '<br />'; } } $qansdisp .= '<div class="' . $sValue . '_div" style="float:left; width:auto; background:#e5e5e5; margin:4px; padding:5px; width:22%;"><strong style="background:white; width:100%;">' . $tValue . '</strong> <br /> <div>' . $anslist . '</div> <div><span style="width:100%; background:red; color:white; padding:0px 4px; cursor:pointer;" onclick=removeNode("' . $sValue . '_div");>X</span></div> </div>'; } return $qansdisp; }
$current_target = 'authorize'; break; default: $current_target = 'last'; break; } // iterate through questions $problems = ''; $construction_status = 0; $question_ids_arr = explode('|', $question_ids); for ($j = 1; $j < sizeof($question_arr); $j++) { // 0 is construction id if ($question_arr[$j] != '0') { echo $i . '/' . $j . ':' . $question_arr[$j] . ' - '; $construction_status = 1; $question_text = getQuestionText($question_ids_arr[$j - 1]); $problems .= '<i>' . $question_text . '</i><br/>' . $question_arr[$j] . '<br/>'; } } $next_status = 0; if ($construction_status == 1) { $next_status = $current_status + 1; } else { $next_status = 0; $problems = 'i.O.'; } // TODO: format answers + get question text // TODO: switch between check, maintain and authorize $update = "UPDATE constructions SET current_status=" . $next_status . ", " . $current_target . "_checked=NOW(), " . $current_target . "_controller='" . $name . "', " . $current_target . "_comment='" . $problems . "' WHERE id='" . $construction_id . "'"; echo 'Update: ' . $update; mysqli_query($link, $update);