diff --git a/functions/functions.operator.php b/functions/functions.operator.php index 7738aab8..1b99b5be 100644 --- a/functions/functions.operator.php +++ b/functions/functions.operator.php @@ -904,7 +904,7 @@ function get_limesurvey_url($operator_id) if ($case_id) { $sid = get_limesurvey_id($operator_id); - $url = LIME_URL . "index.php?loadall=reload&sid=$sid&token=$case_id&lang=" . DEFAULT_LOCALE; + $url = LIME_URL . "index.php?sid=$sid&token=$case_id&lang=" . DEFAULT_LOCALE; $questionnaire_id = get_questionnaire_id($operator_id); //get prefills @@ -1142,100 +1142,12 @@ function copy_row_quota($questionnaire_id,$sample_import_id,$copy_sample_import_ AND sample_import_id = '$sample_import_id'"; $db->Execute($sql); - update_quotas($questionnaire_id); $db->CompleteTrans(); } -/** - * Copy row quotas from one sample to another with blocking - * Set quota_reached to 0 by default - * - * @param int $questionnaire_id - * @param int $sample_import_id - * @param int $copy_sample_import_id The sample_import_id to copy to - */ -function copy_row_quota_with_blocking($questionnaire_id,$sample_import_id,$copy_sample_import_id) -{ - global $db; - - $db->StartTrans(); - - //Set quota_reached to 0 always - - $sql = "INSERT INTO questionnaire_sample_quota_row (questionnaire_id,sample_import_id,lime_sgqa,value,comparison,completions,exclude_var,exclude_val,quota_reached,description) - SELECT questionnaire_id, $copy_sample_import_id, lime_sgqa,value,comparison,completions,exclude_var,exclude_val,quota_reached,description - FROM questionnaire_sample_quota_row - WHERE questionnaire_id = '$questionnaire_id' - AND sample_import_id = '$sample_import_id'"; - - $db->Execute($sql); - - - update_quotas($questionnaire_id); - - $db->CompleteTrans(); -} - -/** - * Copy row quotas from one sample to another and adjust completion number appropriately to completed in the sample. - * - * @param int $questionnaire_id - * @param int $sample_import_id - * @param int $copy_sample_import_id The sample_import_id to copy to - */ -function copy_row_quota_with_adjusting($questionnaire_id,$sample_import_id,$copy_sample_import_id) -{ - global $db; - - // Copy quotas (defalt Quexs function) - copy_row_quota_with_blocking($questionnaire_id,$sample_import_id,$copy_sample_import_id); - - $db->StartTrans(); - - // Select quotas from the old sample rows and calculate - $sql = "SELECT questionnaire_sample_quota_row_id,q.questionnaire_id,sample_import_id,lime_sgqa,value,comparison,completions,quota_reached,q.lime_sid,qsq.exclude_var,qsq.exclude_val - FROM questionnaire_sample_quota_row as qsq, questionnaire as q - WHERE qsq.questionnaire_id = '$questionnaire_id' - AND q.questionnaire_id = '$questionnaire_id' - #AND qsq.quota_reached != '1' - AND qsq.lime_sgqa != -1 - AND sample_import_id='".$sample_import_id."' - "; - - $rs = $db->GetAll($sql); - - if (isset($rs) && !empty($rs)) - { - //include limesurvey functions - include_once(dirname(__FILE__).'/functions.limesurvey.php'); - - //update all row quotas for this questionnaire - foreach($rs as $r) - { - $completions = limesurvey_quota_completions($r['lime_sgqa'],$r['lime_sid'],$r['questionnaire_id'],$r['sample_import_id'],$r['value'],$r['comparison']); - if ($completions > 0) - { - //Update adjusting the completion number - $sql = "UPDATE questionnaire_sample_quota_row - SET completions = IF(completions>".$completions.",(completions-".$completions."),0), quota_reached = IF(quota_reached = 0,IF(completions=0,1,0),1) - WHERE questionnaire_id = '".$questionnaire_id."' - AND sample_import_id='".$copy_sample_import_id."' - AND lime_sgqa='".$r['lime_sgqa']."' - AND value='".$r['value']."' - AND comparison='".$r['comparison']."'"; - - $db->Execute($sql); - } - - } - } - - $db->CompleteTrans(); -} - /** * Update the row quota table * @@ -1341,7 +1253,7 @@ function end_case($operator_id) WHERE c.case_id = '$case_id' AND c.outcome_id = o.outcome_id AND o.tryanother = 0 - AND o.outcome_type_id = 4 + AND (o.outcome_type_id = 4) ORDER BY c.call_id DESC LIMIT 1"; @@ -1397,17 +1309,20 @@ function end_case($operator_id) ORDER BY o.contacted DESC,c.call_id DESC LIMIT 1"; - $t = $db->GetRow($sql); + $t = $db->GetRow($sql); - if (!empty($t)) - $outcome = $t['outcome_id']; + if (!empty($t)) + { + $outcome = $t['outcome_id']; + } } else if ($count >= 1) //one or more numbers to be tried again - first code as eligible if ever eligible... { //$r[0]['contact_phone_id']; + //code as eligible if ever eligible, or if referred to the supervisor, code as that if last call $sql = "SELECT c.outcome_id as outcome_id FROM `call` as c - JOIN outcome AS o ON ( c.outcome_id = o.outcome_id AND o.eligible = 1) + JOIN outcome AS o ON ( c.outcome_id = o.outcome_id AND (o.eligible = 1 OR o.outcome_type_id = 2) ) WHERE c.case_id = '$case_id' ORDER BY c.call_id DESC";