Exemplo n.º 1
0
function pdfoutput__make_part_list($experiment_id, $session_id = "", $pstatus = "", $focus = "", $sort = "", $file = false, $tlang = "")
{
    global $settings;
    if ($tlang == "") {
        global $lang;
    } else {
        $lang = load_language($tlang);
    }
    $experiment = orsee_db_load_array("experiments", $experiment_id, "experiment_id");
    $pstatuses = expregister__get_participation_statuses();
    if ($session_id) {
        $clause = "session_id = '" . $session_id . "'";
        $title = lang('registered_subjects');
    } elseif (isset($pstatuses[$pstatus])) {
        $clause = "pstatus_id = '" . $pstatus . "'";
        if ($pstatus == 0) {
            $clause .= " AND session_id != 0";
        }
        $title = lang('subjects_in_participation_status') . ' "' . $pstatuses[$pstatus]['internal_name'] . '"';
    } elseif ($focus == 'enroled') {
        $clause = "session_id != 0";
        $title = lang('registered_subjects');
    }
    $cols = participant__get_result_table_columns('session_participants_list_pdf');
    if ($session_id) {
        unset($cols['session_id']);
    }
    // load sessions of this experiment
    $pars = array(':experiment_id' => $experiment_id);
    $query = "SELECT *\n\t\t\tFROM " . table('sessions') . "\n\t\t\tWHERE experiment_id= :experiment_id\n\t\t\tORDER BY session_start";
    $result = or_query($query, $pars);
    global $thislist_sessions;
    $thislist_sessions = array();
    while ($line = pdo_fetch_assoc($result)) {
        $thislist_sessions[$line['session_id']] = $line;
    }
    // load participant data for this session/experiment
    $pars = array(':experiment_id' => $experiment_id);
    $select_query = "SELECT * FROM " . table('participate_at') . ", " . table('participants') . "  \n\t\t\t\t\tWHERE " . table('participate_at') . ".experiment_id= :experiment_id\n\t\t\t\t\tAND " . table('participate_at') . ".participant_id=" . table('participants') . ".participant_id\n\t\t\t\t\tAND (" . $clause . ")";
    $order = query__get_sort('session_participants_list_pdf', $sort);
    if (!$order) {
        $order = table('participants') . ".participant_id";
    }
    $select_query .= " ORDER BY " . $order;
    // get result
    $result = or_query($select_query, $pars);
    $participants = array();
    while ($line = pdo_fetch_assoc($result)) {
        $participants[] = $line;
    }
    $result_count = count($participants);
    // load sessions of this experiment
    $pars = array(':texperiment_id' => $experiment_id);
    $squery = "SELECT *\n            FROM " . table('sessions') . "\n\t\t\tWHERE experiment_id= :texperiment_id \n            ORDER BY session_start";
    $result = or_query($squery, $pars);
    $thislist_sessions = array();
    while ($line = pdo_fetch_assoc($result)) {
        $thislist_sessions[$line['session_id']] = $line;
    }
    // reorder by session date if ordered by session id
    if ($sort == "session_id") {
        $temp_participants = $participants;
        $participants = array();
        foreach ($thislist_sessions as $sid => $s) {
            foreach ($temp_participants as $p) {
                if ($p['session_id'] == $sid) {
                    $participants[] = $p;
                }
            }
        }
    }
    unset($temp_participants);
    // determine table title
    $table_title = $experiment['experiment_public_name'];
    if ($session_id) {
        $table_title .= ', ' . lang('session') . ' ' . str_replace(" ", " ", session__build_name($thislist_sessions[$session_id]));
    }
    $table_title .= ' - ' . $title;
    // determine table headings
    $table_headings = participant__get_result_table_headcells_pdf($cols);
    $table_data = array();
    $pnr = 0;
    foreach ($participants as $p) {
        $pnr++;
        $p['order_number'] = $pnr;
        $row = participant__get_result_table_row_pdf($cols, $p);
        $table_data[] = $row;
    }
    // prepare pdf
    include_once '../tagsets/class.ezpdf.php';
    $pdf = new Cezpdf('a4', 'landscape');
    $pdf->selectFont('../tagsets/fonts/Times-Roman.afm');
    $fontsize = $settings['participant_list_pdf_table_fontsize'] ? $settings['participant_list_pdf_table_fontsize'] : 10;
    $titlefontsize = $settings['participant_list_pdf_title_fontsize'] ? $settings['participant_list_pdf_title_fontsize'] : 12;
    $y = $pdf->ezTable($table_data, $table_headings, $table_title, array('gridlines' => 31, 'showHeadings' => 1, 'shaded' => 2, 'shadeCol' => array(1, 1, 1), 'shadeCol2' => array(0.9, 0.9, 0.9), 'fontSize' => $fontsize, 'titleFontSize' => $titlefontsize, 'rowGap' => 1, 'colGap' => 3, 'innerLineThickness' => 0.5, 'outerLineThickness' => 1, 'maxWidth' => 800, 'width' => 800, 'protectRows' => 2));
    if ($file) {
        $pdffilecode = $pdf->output();
        return $pdffilecode;
    } else {
        $pdf->ezStream(array('Content-Disposition' => 'participant_list.pdf', 'Accept-Ranges' => 0, 'compress' => 1));
    }
}
         $assigned_count = count($assign_ids);
         log__admin("experiment_assign_participants", "experiment:" . $experiment['experiment_name'] . ", count:" . $assigned_count);
         $done = query__save_query($_SESSION['lastquery_assign_' . $experiment_id], 'assign', $experiment_id, array('assigned_count' => $assigned_count, 'selected' => $selected, 'totalcount' => $totalcount));
     } else {
         $assigned_count = 0;
     }
     $_SESSION['assign_ids_' . $experiment_id] = array();
     message($assigned_count . ' ' . lang('xxx_participants_assigned'));
     redirect('admin/' . thisdoc() . '?experiment_id=' . $experiment_id);
 } elseif (isset($_REQUEST['search_submit']) || isset($_REQUEST['search_sort'])) {
     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
     if (isset($_REQUEST['search_sort'])) {
         $posted_query_json = $_SESSION['lastquery_assign_' . $experiment_id];
         $query_id = $_SESSION['lastqueryid_assign_' . $experiment_id];
         $posted_query = $json->decode($posted_query_json);
         $sort = query__get_sort('assign', $_REQUEST['search_sort']);
         // sanitize sort
     } else {
         // store new query in session
         $query_id = time();
         if (isset($_REQUEST['form'])) {
             $posted_query = $_REQUEST['form'];
         } else {
             $posted_query = array('query' => array());
         }
         $posted_query_json = $json->encodeUnsafe($posted_query);
         $_SESSION['lastquery_assign_' . $experiment_id] = $posted_query_json;
         $_SESSION['lastqueryid_assign_' . $experiment_id] = $query_id;
         $sort = query__load_default_sort('assign', $experiment_id);
     }
     if (check_allow('participants_edit')) {
 if (!$session_id || !isset($show_payment_budgets) || $show_payment_budgets == false) {
     unset($cols['payment_budget']);
 }
 if (!$session_id || !isset($show_payment_types) || $show_payment_types == false) {
     unset($cols['payment_type']);
 }
 if (!$session_id) {
     unset($cols['payment_amount']);
 }
 // load participant data for this session/experiment
 $pars = array(':texperiment_id' => $experiment_id);
 $query = "SELECT * FROM " . table('participate_at') . ", " . table('participants') . "  \n\t\t\t\t\tWHERE " . table('participate_at') . ".experiment_id= :texperiment_id \n\t\t\t\t\tAND " . table('participate_at') . ".participant_id=" . table('participants') . ".participant_id\n\t\t\t\t\tAND (" . $clause . ")";
 foreach ($clause_pars as $p => $v) {
     $pars[$p] = $v;
 }
 $order = query__get_sort('session_participants_list', $sort);
 // sanitize sort or load default if empty
 if (!$order) {
     $order = table('participants') . ".participant_id";
 }
 //??
 $query .= " ORDER BY " . $order;
 // get result
 $result = or_query($query, $pars);
 $participants = array();
 $plist_ids = array();
 while ($line = pdo_fetch_assoc($result)) {
     $participants[] = $line;
     $plist_ids[] = $line['participant_id'];
 }
 $result_count = count($participants);
Exemplo n.º 4
0
    show_message();
}
if ($proceed) {
    if (isset($_REQUEST['search_submit']) || isset($_REQUEST['search_sort'])) {
        $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
        if (isset($_REQUEST['search_sort'])) {
            // use old query
            if ($active) {
                $posted_query_json = $_SESSION['lastquery_participants_search_active'];
                $query_id = $_SESSION['lastqueryid_participants_search_active'];
                $sort = query__get_sort('participants_search_active', $_REQUEST['search_sort']);
                // sanitize sort
            } else {
                $posted_query_json = $_SESSION['lastquery_participants_search_all'];
                $query_id = $_SESSION['lastqueryid_participants_search_all'];
                $sort = query__get_sort('participants_search_all', $_REQUEST['search_sort']);
                // sanitize sort
            }
            $posted_query = $json->decode($posted_query_json);
        } else {
            // store new query in session
            $query_id = time();
            if (isset($_REQUEST['form'])) {
                $posted_query = $_REQUEST['form'];
            } else {
                $posted_query = array('query' => array());
            }
            $posted_query_json = $json->encodeUnsafe($posted_query);
            if ($active) {
                $_SESSION['lastquery_participants_search_active'] = $posted_query_json;
                $_SESSION['lastqueryid_participants_search_active'] = $query_id;