diff --git a/CHANGELOG b/CHANGELOG index 4f2371b0..13415e33 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -63,6 +63,9 @@ ALTER TABLE `outcome` ADD `default` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COM /* -- define and set mandatory(constant) outcome_id's --*/ UPDATE `outcome` SET `permanent` = '1' WHERE `outcome`.`outcome_id` IN (1,2,3,7,9,10,14,17,18,19) ; +/* -- set AUTO_INCREMENT to 100 @ `outcome` to reserve some id's -- */ +ALTER TABLE `outcome` AUTO_INCREMENT = 100; + /* -- add `outcomes` parameter , define default list of outcome_ID's to be enabled for new questionnaries --*/ ALTER TABLE `questionnaire` ADD `outcomes` VARCHAR(256) NULL DEFAULT '1,2,3,7,9,10,14,17,18,19' COMMENT 'Comma-separated string of outcomes defined for the questionnaire' AFTER `enabled`; diff --git a/admin/set_outcomes.php b/admin/set_outcomes.php index 9f11402e..cbbc847d 100644 --- a/admin/set_outcomes.php +++ b/admin/set_outcomes.php @@ -45,11 +45,12 @@ $js_foot = array( "../js/custom.js" ); -global $db; - +global $db; if (isset($_POST['default']) && isset($_POST['save'])){ + $db->StartTrans(); + $sql = "UPDATE `outcome` as o SET `default` = 0 WHERE o.permanent != 1"; @@ -66,25 +67,27 @@ if (isset($_POST['default']) && isset($_POST['save'])){ SET `default` = 1 WHERE o.permanent != 1 AND o.outcome_id IN ($sel)"; - - $db->Execute($sql); + $db->Execute($sql); } if(!empty($_POST['delay']) && $_SESSION['user'] === "admin" ){ - - foreach($_POST['delay'] as $n => $val) - { - $sql = "UPDATE `outcome`SET default_delay_minutes = $val WHERE outcome_id = $n"; - $db->Execute($sql); - } + foreach($_POST['delay'] as $n => $val) { + $db->Execute("UPDATE `outcome`SET default_delay_minutes = $val WHERE outcome_id = $n"); + } + } + if(!empty($_POST['delete']) && $_SESSION['user'] === "admin" ){ + foreach($_POST['delete'] as $n => $val) { + $db->Execute("DELETE FROM `outcome` WHERE outcome_id = $n AND outcome_id >= 100"); + } } - $_GET['default'] = $_POST['default']; + if($db->CompleteTrans()) $msg_ok = T_("Default outcomes updated"); else $msg_err = T_("Default outcomes NOT updated"); + $_GET['default'] = $_POST['default']; unset($_POST['default']); unset($_POST['save']); } -if (isset($_POST['qid']) && isset($_POST['save'])){ +if (isset($_POST['qid']) && $_POST['qid'] > 0 && isset($_POST['save'])){ //get id's for 'permanent' outcomes $sql = "SELECT o.outcome_id @@ -112,39 +115,98 @@ if (isset($_POST['qid']) && isset($_POST['save'])){ $sql = "UPDATE questionnaire SET outcomes = '$sel' WHERE questionnaire_id = $qid"; - - $db->Execute($sql); + if ($db->Execute($sql)) $msg_ok = T_("Questionnaire outcomes saved"); else $msg_err = T_("Error:") . " " . T("Questionnaire outcomes not saved"); $_GET['qid'] = $_POST['qid']; - unset($_POST['qid']); unset($_POST['save']); } +if ($_SESSION['user'] === "admin" && isset($_POST['addoutcome']) && isset($_POST['save'])){ + if (isset($_POST['description']) && !empty($_POST['description']) && intval($_POST['outcome_type_id']) > 0 ) { + $desc = $_POST['description']; + $outcome_type_id = intval($_POST['outcome_type_id']); + if (isset($_POST['default_delay_minutes'])) $ddm = $_POST['default_delay_minutes']; else $ddm = 0; + if (isset($_POST['contacted'])) $contacted = 1; else $contacted = 0; + if (isset($_POST['tryanother'])) $tryanother = 1; else $tryanother = 0; + if (isset($_POST['tryagain'])) $tryagain = 1; else $tryagain = 0; + if (isset($_POST['eligible'])) $eligible = 1; else $eligible = 0; + if (isset($_POST['require_note'])) $require_note = 1; else $require_note = 0; + if (isset($_POST['calc'])) $calc = $_POST['calc']; else $calc = ""; + if (isset($_POST['aapor_id'])) $aapor_id = $_POST['aapor_id']; else $aapor_id = ""; + if (isset($_POST['default_o'])) $def = 1; else $def = 0; + if (isset($_POST['permanent'])) $perm = 1; else $perm = 0; + + $sql = "INSERT INTO `outcome` VALUES ('NULL','$aapor_id','$desc','$ddm','$outcome_type_id','$tryanother','$contacted','$tryagain','$eligible','$require_note','$calc','$def','$perm')"; + if ($db->Execute($sql)) { + $msg_ok = T_("Custom outcome") . " " . $desc . " " . T_("saved"); + } + else $msg_err = T_("Error:") . " " . T_("New outcome not saved"); + } + else { + if (empty($_POST['description'])) $ms = T_("Description"); + if ($_POST['outcome_type_id'] <= 0) $ms = T_("Outcome type"); + $msg_err = T_("Error:") . " " . $ms . " " . T_("is not set"); + $_GET['addoutcome'] = $_POST['addoutcome']; + } + + if (isset($_POST['h']) && isset($_POST['v'])) {$h = $_POST['h']; $_GET[$h] = $_POST['v'];} + unset($_POST['addoutcome']); + unset($_POST['save']); +} /*select outcomes list*/ -if (isset($_GET['default'])) { $title = T_("Set default outcomes"); } -else if (isset($_GET['qid'])){ $title = T_("Set questionnaire outcomes"); $qid = intval($_GET['qid']); } +if (isset($_GET['default'])) $title = T_("Set default outcomes"); +else if (isset($_GET['qid'])) $title = T_("Set questionnaire outcomes"); +else if (isset($_GET['addoutcome'])) $title = T_("ADD custom outcome"); else die(); xhtml_head($title,true,$css,$js_head); + +/* to add customm outcome*/ +if ($_SESSION['user'] === "admin" && isset($_GET['addoutcome'])){ + + $rs[] = ["description" => "", "value" => ""]; + $sql = "SELECT outcome_type_id as value,description FROM `outcome_type`"; + $ot = $db->GetAll($sql); translate_array($ot, array("description")); + $select = display_chooser($ot,"outcome_type_id","outcome_type_id",true,false,false,true,false,false); + $rs[] = ["description" => "", "value" => "{$select}"]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + $rs[] = ["description" => "", "value" => ""]; + + $hid = "addoutcome"; $value = "newoutcome"; $h = $_GET['h']; $v = $_GET['v']; + $row = array("description","value"); + $hdr = array(T_("Description"),T_("Value")); + $sbtn = T_("Save custom Outcome"); + $class = "table-hover table-condensed"; +} + /* for questionnire outcomes */ if (isset($_GET['qid'])) { + $qid = intval($_GET['qid']); if($qid == 0) $qid = false; - print "
" . template_replace($r['rs_answeringmachine'],$operator_id,$case_id) . "
"; + if (!empty($r['rs_answeringmachine'])) print "" . T_("Do not leave a message, please hang up") . "
"; + print "" . T_("Do not leave a message, please hang up") . "
"; + +print "" . template_replace($r['rs_answeringmachine'],$operator_id,$case_id) . "
"; -} -else - print "" . T_("Do not leave a message, please hang up") . "
"; - -?> - - - - - - - diff --git a/rs_business.php b/rs_business.php index 5dc0a140..cfe5831d 100644 --- a/rs_business.php +++ b/rs_business.php @@ -20,11 +20,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * - * @author Adam Zammit" . T_("Sorry to bother you, I have called the wrong number") . "
"; -?> - +print "" . template_replace($r['rs_callback'],$operator_id,$case_id) . "
"; -print "" . T_("You are: ") . round(limesurvey_percent_complete($case_id),1) . T_("% complete") . "
"; +if (!empty($r['rs_callback'])) print "" . T_("Survey is") . " " . round(limesurvey_percent_complete($case_id),1) . " % " . T_("complete") . "
"; -//display outcomes +print "" . template_replace($r['rs_callback'],$operator_id,$case_id) . "
"; -print "" . T_("You are: ") . round(limesurvey_percent_complete($case_id),1) . T_("% complete") . "
"; - - -//display outcomes - -?> - - - - - diff --git a/rs_intro.php b/rs_intro.php index c74c68f8..e2179dd8 100644 --- a/rs_intro.php +++ b/rs_intro.php @@ -20,11 +20,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * - * @author Adam Zammit". template_replace($r['rs_intro'],$operator_id,$case_id) . "
"; + //display outcomes + $outcomes = $db->GetOne("SELECT q.outcomes FROM `questionnaire` as q WHERE q.questionnaire_id = $questionnaire_id");// + $outcomes = explode(",",$outcomes); + $des = $db->GetAll("SELECT description FROM outcome WHERE outcome_id IN (1,2,3,6,8,16,17,18,30,31)"); + translate_array($des,array("description")); -//display outcomes + print "". template_replace($r['rs_intro'],$operator_id,$case_id) . "
"; -print "" . template_replace($r['rs_project_end'],$operator_id,$case_id) . "
"; +if (!empty($r['rs_project_end'])) print "" . template_replace($r['rs_project_end'],$operator_id,$case_id) . "
"; + +print ""; if (!is_voip_enabled($operator_id) && AUTO_COMPLETE_OUTCOME) { end_call($operator_id,10); - print "
" . T_("Call automatically ended with outcome: Complete") . "
"; + + print T_("Call automatically ended with outcome:") . " " . T_("Complete") . ""; + //check for alternate interface + if (ALTERNATE_INTERFACE && !is_voip_enabled($operator_id)) + print " " . T_("End case") . ""; } else -{ - ?> - - "; + else + print "href=\"javascript:parent.poptastic('call.php?defaultoutcome=10');\">"; + + print T_("Complete") . ""; } + +print ""; + xhtml_foot(); ?> diff --git a/rs_project_end_interface2.php b/rs_project_end_interface2.php deleted file mode 100644 index fdc2d303..00000000 --- a/rs_project_end_interface2.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Australian Consortium for Social and Political Research Inc 2007,2008 - * @package queXS - * @subpackage user - * @link http://www.acspri.org.au/ queXS was writen for Australian Consortium for Social and Political Research Incorporated (ACSPRI) - * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 - * - */ - -/** - * Configuration file - */ -include_once ("config.inc.php"); - -/** - * Database file - */ -include_once ("db.inc.php"); - -/** - * Authentication - */ -require ("auth-interviewer.php"); - - -/** - * XHTML functions - */ -include_once ("functions/functions.xhtml.php"); - -/** - * Operator functions - */ -include_once ("functions/functions.operator.php"); - - -$js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); - -if (AUTO_LOGOUT_MINUTES !== false) -{ - $js[] = "js/childnap.js"; -} - - - -xhtml_head(T_("Respondent Selection - Project end"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); - -$operator_id = get_operator_id(); -$case_id = get_case_id($operator_id); -$questionnaire_id = get_questionnaire_id($operator_id); - -//display introduction text -$sql = "SELECT rs_project_end - FROM questionnaire - WHERE questionnaire_id = '$questionnaire_id'"; - -$r = $db->GetRow($sql); - -print "" . template_replace($r['rs_project_end'],$operator_id,$case_id) . "
"; - -if (!is_voip_enabled($operator_id) && AUTO_COMPLETE_OUTCOME) -{ - end_call($operator_id,10); - print "" . T_("Call automatically ended with outcome: Complete - End case") . "
"; -} -else -{ - ?> - - diff --git a/rs_project_intro.php b/rs_project_intro.php index 33044e8c..2d70c166 100644 --- a/rs_project_intro.php +++ b/rs_project_intro.php @@ -20,11 +20,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * - * @author Adam Zammit" . template_replace($r['rs_project_intro'],$operator_id,$case_id) . "
"; +if (!empty($r['rs_project_intro'])) print "" . template_replace($r['rs_project_intro'],$operator_id,$case_id) . "
"; - - -//display outcomes - -?> - - - - - - - - - - diff --git a/rs_quota_end.php b/rs_quota_end.php index 2dce2432..22e80176 100644 --- a/rs_quota_end.php +++ b/rs_quota_end.php @@ -57,33 +57,28 @@ include ("functions/functions.operator.php"); $js = array("js/popup.js","include/jquery/jquery-1.4.2.min.js","include/jquery-ui/jquery-ui.min.js"); -if (AUTO_LOGOUT_MINUTES !== false) -{ - $js[] = "js/childnap.js"; -} +if (AUTO_LOGOUT_MINUTES !== false) $js[] = "js/childnap.js"; -xhtml_head(T_("Respondent Selection - Project Quota End"),true,array("css/rs.css","include/jquery-ui/jquery-ui.min.css"), $js); +xhtml_head(T_("Respondent Selection") . " - " . T_("Project Quota End"),true,array("include/bootstrap/css/bootstrap.min.css","css/rs.css"), $js); $operator_id = get_operator_id(); $case_id = get_case_id($operator_id); $questionnaire_id = get_questionnaire_id($operator_id); -print "" . template_replace($_GET['message'],$operator_id,$case_id) . "
"; +if (isset($_GET['message'])) print "" . template_replace($_GET['message'],$operator_id,$case_id) . "
"; +$des = $db->GetOne("SELECT description FROM outcome WHERE outcome_id = 32"); + +print "