<?php require_once('includes/requirepost.inc.php'); require_once('includes/question.inc.php'); $qn_id=TPOST('qn_id'); $action=TPOST('action'); $nexturl=TPOST('nexturl'); $qc_id=TPOST('qc_id'); $a_text=TPOST('a_text'); $answer_data=array(); if (is_array($qc_id)) $answer_data+=$qc_id; if ($a_text) $answer_data+=$a_text; purge_array_by_key_prefix($_SESSION,'reserv.transfercache.'); $errorareas=array(); $errorareamap=array(); if ($action=='transfer') $DBConn->connect(true); else if ($action=='submit') $DBConn->connect(); if ($DBConn->connected()) { $questionnaire_question=db_load_questionnaires_questions($DBConn,$qn_id); $q_id2qnq=rowset2map($questionnaire_question,'q_id'); $answer_data['qn_id']=$qn_id; foreach ($q_id2qnq as $q_id=>$qnq) { if ($qnq['qnq_required'] && !$answer_data[$q_id]) { $errorareas['ERROR-MISS-REQUIRED']=array(0); $errorareamap[$q_id]['ERROR-MISS-REQUIRED']=array(0); } } } if ($errorareas) { $_SESSION['reserv.inputcache.domain']='questionnaire.run'; $_SESSION['reserv.inputcache.data']=array( 'answer_data'=>$answer_data, 'errorareamap'=>$errorareamap ); $_SESSION['reserv.inputcache.errorareas']=$errorareas; redirect("qx-cmd-questionnaire.run-qn_id-".$qn_id."-op-revise.html".($nexturl?"?nexturl=".urlencode($nexturl):"")); } else if ($action=='transfer') { $_SESSION['reserv.transfercache.domain']='questionnaire.run'; $_SESSION['reserv.transfercache.data']=array($qn_id=>$answer_data); redirect($nexturl); } else if ($action=='submit') { $DBConn->begin(true); save_questionnaire_answer_set($DBConn,$qn_id,current_mb_id(),$answer_data); $DBConn->commit(); purge_array_by_key_prefix($_SESSION,'reserv.inputcache.'); redirect("qx-cmd-questionnaire.run.save.done.html"); } else redirect("./"); ?>