\n\n"; echo "\t"; if ($proposalIdValues) echo ''; echo ''; if ($proposalIdValues) echo ''; echo "\n"; foreach ($responseArray as $key => $value) { echo "\t'; break; case 'f': echo ' class="declined">'; break; default: echo '>'; break; } if ($proposalIdValues) echo ""; echo ''; if ($proposalIdValues) echo ''; echo "\n"; } echo "
#' . htmlspecialchars(_('proposal'), ENT_COMPAT, 'ISO-8859-1') . '' . htmlspecialchars($valueColumnTitle, ENT_COMPAT, 'ISO-8859-1') . '
$key' . htmlspecialchars(getProposalDateTimeStr($value), ENT_COMPAT, 'ISO-8859-1') . '' . number_format($proposalIdValues[$key], 2) . '
\n\n"; } function condorcetTable_NumToAbc($number) { return chr($number+ord('a')); // ToDo: Think for $number > 26! } function condorcetTable($cm) { $threshold = 2; // number of proposals that will be shown completely echo "
\n\n"; echo "\t\n"; $c = 0; foreach ($cm as $proposalIdRow => $proposalArray) { echo "\t"; $fullname = htmlspecialchars(getProposalDateTimeStr($proposalIdRow), ENT_COMPAT, 'ISO-8859-1'); if (count($cm) > $threshold) echo html_element('th', array('title' => $fullname), (string) condorcetTable_NumToAbc($c)); else echo html_element('th', $fullname); foreach ($proposalArray as $proposalIdCol => $value) { echo ''; } echo "\n"; $c++; } echo "
"; $c = 0; foreach (array_keys($cm) as $proposalId) { $fullname = htmlspecialchars(getProposalDateTimeStr($proposalId), ENT_COMPAT, 'ISO-8859-1'); if (count($cm) > $threshold) echo html_element('th', array('title' => $fullname), (string) condorcetTable_NumToAbc($c)); else echo html_element('th', $fullname); $c++; } echo "
' . ($proposalIdCol == $proposalIdRow ? '\\' : $value) . '
\n
\n"; } $appointmentid = isset($_GET['id']) ? $_GET['id'] : ''; if (empty($appointmentid)) die('No id specified'); if (!is_numeric($appointmentid)) die('Invalid id'); $appointmentid = (int) $appointmentid; if (isset($_GET['comments'])) { $showcomments = (int) $_GET['comments']; if ($showcomments < 0 || $showcomments > 2) $showcomments = 0; } else $showcomments = 0; $appointment = getAppointment($appointmentid); extract(html_escape_array($appointment)); $proposals = getProposals($appointmentid); $participants = getParticipants($appointmentid); $appointmentrights = getAppointmentRights($appointmentid, $_SESSION['person']['id']); $expired = empty($expire_date) ? FALSE : strtotime($expire_date)+84600 < time(); // 84600 is a day. ?> <?php echo $title; ?> 'hint'), $_SESSION['editdbmsg']); unset($_SESSION['editdbmsg']); if ($appointmentrights) { echo html_element('h1', $title); if ($description) echo html_element('p', array('class' => 'description'), $description); if ($location) echo html_element('p', array('class' => 'location'), $location); if ($expired) echo html_element('p', array('id' => 'expirewarning'), _('This appointment has expired.')); // Available proposals // ------------------- ?>

'noproposals'), _('There are no proposals.')); else { echo "\n"; // title echo "\t'; foreach ($participants as $person) { extract(html_escape_array($person)); echo ""; } echo "\n"; // responses foreach ($proposals as $proposal) { extract(html_escape_array($proposal)); echo "\t'; $respones = getResponses($id); foreach ($respones as $response) { extract(html_escape_array($response)); if ($showcomments == '1') $comment = htmlspecialchars(text_cut($response['comment'], 15), ENT_COMPAT, 'ISO-8859-1'); echo ""; } echo "\n"; } echo "
" . htmlspecialchars(_('proposal'), ENT_COMPAT, 'ISO-8859-1') . '"; if ($email) echo html_element('a', array('href' => "mailto:$email"), $fullname, TRUE); else echo(htmlspecialchars($fullname, ENT_COMPAT, 'ISO-8859-1')); echo "
$date $time (" . htmlspecialchars(strftime('%a', $timestamp), ENT_COMPAT, 'ISO-8859-1') . ')"; if ($value) echo "$value"; if ($showcomments) echo ' ', $comment; echo "
\n"; echo '

'; if ($showcomments != 0) echo '", htmlspecialchars(_('No comments'), ENT_COMPAT, 'ISO-8859-1'), ' '; if ($showcomments != 1) echo '", htmlspecialchars(_('Short comments'), ENT_COMPAT, 'ISO-8859-1'), ' '; if ($showcomments != 2) echo '", htmlspecialchars(_('Full comments'), ENT_COMPAT, 'ISO-8859-1'), ''; echo "

\n"; // Analysis // -------- if ($expired || $appointmentrights['manageappointment']) { ?>

'noproposals'), _('There are no responses to be analyzed.')); else { if ($DEBUG) {echo("---Time-Diff: " . (microtime_float()-$t0) . "---");} // ---debug --- echo html_element('h3', _('Mean value analysis'), TRUE); echo html_element('p', array('class' => 'description'), _('For each proposal, the mean value of the responses is calculated.'), TRUE); analysisTable($responseArray, $proposalIdValues, _('mean value')); if ($DEBUG) {echo("---Time-Diff: " . (microtime_float()-$t0) . "---");} // ---debug --- echo html_element('h3', _('Negative majority analysis'), TRUE); echo html_element('p', array('class' => 'description'), _('For each person, the worst proposal gets zero points, all other proposals one point. Finally the sum is calculated.'), TRUE); list($responseArray, $proposalIdValues) = analyzeNegativeMajority(getResponseArray($appointmentid), $approvaldesc); analysisTable($responseArray, $proposalIdValues, _('points')); if ($DEBUG) {echo("---Time-Diff: " . (microtime_float()-$t0) . "---");} // ---debug --- echo html_element('h3', _('Condorcet analysis'), TRUE); echo html_element('p', array('class' => 'description'), htmlspecialchars(_('Cf. '), ENT_COMPAT, 'ISO-8859-1') . html_element('a', array('href'=>_('http://en.wikipedia.org/wiki/Condorcet_method')), _('http://en.wikipedia.org/wiki/Condorcet_method'), TRUE) . htmlspecialchars(_('. Below you find a table with the Condorcet winner(s) and the beat matrix.'), ENT_COMPAT, 'ISO-8859-1')); list($responseArray, $condorcetMatrix) = analyzeCondorcet(getResponseArray($appointmentid), $approvaldesc); analysisTable($responseArray, NULL, NULL); condorcetTable($condorcetMatrix); if ($DEBUG) {echo("---Time-Diff: " . (microtime_float()-$t0) . "---");} // ---debug --- } } // Own responses // ------------- // don't show if expired except the user is manager if (!$expired || $appointmentrights['manageappointment']) { ?>

= date(now()) order by date"; $data = pg_u_query_assoc($db_conn, $sql); $sql = "select id, date || ', ' || to_char(time, 'HH24:MI') || to_char(date, ' (Dy)') as datetime from proposal where appointmentid=$appointmentid and date >= date(now()) order by date"; $lookup_hash = array_to_hash(pg_u_query_num($db_conn, $sql)); $sql = "select id, date || ', ' || to_char(time, 'HH24:MI') || to_char(date, ' (Dy)') as datetime from proposal where appointmentid=$appointmentid and date >= date(now()) and id not in (select proposalid from response where personid=" . $_SESSION['person']['id'] . ") order by date"; $insert_hash = array_to_hash(pg_u_query_num($db_conn, $sql)); $columns = array( new DiOnlyInputSelect('proposalid:', _('proposal'), NULL, $lookup_hash, $insert_hash), new DiTextEdit('value', _('value'), NULL, 3), new DiTextEdit('comment', _('comment'), NULL, 50), new DiHidden('personid:', (string) $_SESSION['person']['id']) ); echo html_createEditForm( 'cgi-bin/editdb.php', basename($_SERVER['REQUEST_URI']), 'response', $columns, $data, // Array of rows, that are again arrays of columns count($insert_hash) > 0, TRUE, TRUE); } // if not expired } // if (count($proposals) > 0) // Manage proposals // ---------------- if ((!$expired || $appointmentrights['manageappointment']) && ($appointmentrights['insertproposal'] || $appointmentrights['updateproposal'] || $appointmentrights['deleteproposal'])) { ?>

Person and appointment don't go well together ...