function printGeneral($show_subtitle = true, $allow_edit = true) { if ($show_subtitle) { show_page_subtitle(_T('generic_subtitle_general'), 'cases_intro'); } echo '<ul class="info">'; // TODO: fix html // Author echo '<li>' . '<span class="label2">' . _Ti('case_input_author') . '</span>' . '<span class="value2">' . get_author_link($this->data) . '</span>' . "</li>\n"; // Date start echo '<li>' . '<span class="label2">' . _Ti('time_input_date_start') . '</span>' . '<span class="value2">' . format_date($this->data['date_start']) . '</span>' . "</li>\n"; // Date end echo '<li>' . '<span class="label2">' . _Ti('time_input_date_end') . '</span>' . '<span class="value2">' . format_date($this->data['date_end']) . '</span>' . "</li>\n"; // Date length echo '<li>' . '<span class="label2">' . _Ti('time_input_length') . '</span>' . '<span class="value2">' . format_time_interval_prefs($this->data['length']) . '</span>' . "</li>\n"; // FU type echo '<li>' . '<span class="label2">' . _Ti('fu_input_type') . '</span>' . '<span class="value2">' . _Tkw('followups', $this->data['type']) . '</span>' . "</li>\n"; // Keywords show_all_keywords('followup', $this->getDataInt('id_followup')); // Conclusion for case/status change /* [ML] 2008-01-30 Should not be necessary, done by get_fu_description() if ($this->data['type'] == 'status_change' || $this->data['type'] == 'stage_change') { $tmp = lcm_unserialize($this->data['description']); var_dump($tmp); echo '<li>' . '<span class="label2">' . _Ti('fu_input_conclusion') . '</span>'; echo '<span class="value2">'; if (read_meta('case_result') == 'yes' && $tmp['result']) echo _Tkw('_crimresults', $tmp['result']) . "<br />\n"; echo _Tkw('conclusion', $tmp['conclusion']) . '</span>'; echo "</li>\n"; echo '<li>' . '<span class="label2">' . _Ti('fu_input_sentence') . '</li>' . '<span class="value2">' . _Tkw('sentence', $tmp['sentence']) . '</span>' . "</li>\n"; } */ // Description $desc = get_fu_description($this->data, false); echo '<li class="large">' . '<span class="label2">' . _Ti('fu_input_description') . '</span>' . '<span class="value2">' . $desc . '</span>' . "</li>\n"; // Sum billed (if activated from policy) if ($this->show_sum_billed == 'yes') { echo '<li>' . '<span class="label2">' . _T('fu_input_sum_billed') . '</span>' . '<span class="value2">'; echo format_money(clean_output($this->data['sumbilled'])); $currency = read_meta('currency'); echo htmlspecialchars($currency); echo '</span>'; echo "</li>\n"; } echo "</ul>\n"; }
if ($meta_sum_billed == 'yes') { echo "<td colspan='3'>"; } else { echo "<td colspan='2'>"; } echo '<ul class="info" style="padding-left: 1.5em">' . $html . "</ul>\n"; echo "</td>"; } } echo "</tr>\n"; } // Show total case hours echo "<tr>\n"; echo "<td><strong>" . _Ti('generic_input_total') . "</strong></td>\n"; echo "<td align='right'><strong>"; echo format_time_interval_prefs($total_time); echo "</strong></td>\n"; if ($meta_sum_billed == 'yes') { echo '<td align="right"><strong>'; echo format_money($total_sum_billed); echo "</strong></td>\n"; } echo "</tr>\n"; echo "</table>\n"; echo "</fieldset>\n"; break; // // Internal requests (expenses) related to this case // // // Internal requests (expenses) related to this case
} echo "<tr>\n"; // Id followup // echo '<td class="tbl_cont_' . $css . '"><img src="images/lcm/dotted_angle.gif" width="15" height="15" align="left" /> ' . $row['id_followup'] . '</td>'; // Start date echo '<td class="tbl_cont_' . $css . '">' . format_date($row['date_start'], 'short') . '</td>'; // Time echo '<td class="tbl_cont_' . $css . '">'; $fu_date_end = vider_date($row['date_end']); if ($prefs['time_intervals'] == 'absolute') { if ($fu_date_end) { echo format_date($row['date_end'], 'short'); } } else { $fu_time = $fu_date_end ? strtotime($row['date_end']) - strtotime($row['date_start']) : 0; echo format_time_interval_prefs($fu_time); } echo '</td>'; // Author initials echo '<td class="tbl_cont_' . $css . '">' . get_person_initials($row) . '</td>'; // Type echo '<td class="tbl_cont_' . $css . '">' . _Tkw('followups', $row['type']) . '</td>'; // Description $short_description = get_fu_description($row); echo '<td class="tbl_cont_' . $css . '">'; echo '<a href="fu_det.php?followup=' . $row['id_followup'] . '" class="content_link">' . $short_description . '</a>'; echo '</td>'; echo "</tr>\n"; } show_list_end($fu_list_pos, $number_of_rows, false, 'fu'); echo "</p>\n";
function show_report_for_user($author, $date_start, $date_end, $type) { if ($type == "case") { $q = "SELECT c.title, c.id_case, \n\t\t\t\t\t\t\t\tsum(IF(UNIX_TIMESTAMP(fu.date_end) > 0,\n\t\t\t\t\t\t\t\t\tUNIX_TIMESTAMP(fu.date_end)-UNIX_TIMESTAMP(fu.date_start), 0)) as time,\n\t\t\t\t\t\t\t\tsum(sumbilled) as sumbilled \n\t\t\t\t\t\t \t FROM lcm_case as c, lcm_followup as fu \n\t\t\t\t\t\t\t WHERE fu.id_case = c.id_case AND fu.id_author = {$author}\n\t\t\t\t\t\t\t\tAND UNIX_TIMESTAMP(date_start) >= UNIX_TIMESTAMP('" . $date_start . "') "; if ($date_end != "-1") { $q .= " AND UNIX_TIMESTAMP(date_end) <= UNIX_TIMESTAMP('" . $date_end . "')"; } $q .= " GROUP BY fu.id_case"; } elseif ($type == "fu") { $q = "SELECT fu.type,\n\t\t\t\t\t\t\t\tsum(IF(UNIX_TIMESTAMP(fu.date_end) > 0,\n\t\t\t\t\t\t\t\t\tUNIX_TIMESTAMP(fu.date_end)-UNIX_TIMESTAMP(fu.date_start), 0)) as time,\n\t\t\t\t\t\t\t\tsum(sumbilled) as sumbilled \n\t\t\t\t\t\t \t FROM lcm_followup as fu \n\t\t\t\t\t\t\t WHERE fu.id_author = {$author}\n\t\t\t\t\t\t\t\tAND UNIX_TIMESTAMP(date_start) >= UNIX_TIMESTAMP('" . $date_start . "') "; if ($date_end != "-1") { $q .= " AND UNIX_TIMESTAMP(date_end) <= UNIX_TIMESTAMP('" . $date_end . "') "; } $q .= " GROUP BY fu.type"; } elseif ($type == "agenda") { $q = "SELECT ap.type,\n\t\t\t\t\t\t\t\tsum(IF(UNIX_TIMESTAMP(ap.end_time) > 0,\n\t\t\t\t\t\t\t\t\tUNIX_TIMESTAMP(ap.end_time)-UNIX_TIMESTAMP(ap.start_time), 0)) as time\n\t\t\t\t\t\t \t FROM lcm_app as ap\n\t\t\t\t\t\t\t WHERE ap.id_author = {$author}\n\t\t\t\t\t\t\t \tAND ap.id_case = 0\n\t\t\t\t\t\t\t\tAND UNIX_TIMESTAMP(start_time) >= UNIX_TIMESTAMP('" . $date_start . "') "; if ($date_end != "-1") { $q .= " AND UNIX_TIMESTAMP(end_time) <= UNIX_TIMESTAMP('" . $date_end . "') "; } $q .= " GROUP BY ap.type"; } $result = lcm_query($q); echo "<p class=\"normal_text\">\n"; echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n"; echo "<tr>\n"; echo '<th class="heading">' . _T('case_subtitle_times_by_' . $type) . "</th>\n"; echo "<th class='heading' width='1%' nowrap='nowrap'>" . _Th('case_input_total_time') . ' (' . _T('time_info_short_hour') . ")" . "</th>\n"; $total_time = 0; $total_sum_billed = 0.0; $meta_sum_billed = read_meta('fu_sum_billed') == 'yes'; $meta_sum_billed &= $type == "case" || $type == "fu"; if ($meta_sum_billed) { $currency = read_meta('currency'); echo "<th class='heading' width='1%' nowrap='nowrap'>" . _Th('fu_input_sum_billed') . ' (' . $currency . ")</th>\n"; } echo "</tr>\n"; // Show table contents & calculate total while ($row = lcm_fetch_array($result)) { echo "<tr>\n"; echo "<!-- Total = " . $total_sum_billed . " - row = " . $row['sumbilled'] . " -->\n"; $total_time += $row['time']; $total_sum_billed += $row['sumbilled']; echo '<td>'; if ($type == "case") { echo '<a class="content_link" href="case_det.php?case=' . $row['id_case'] . '">' . $row['id_case'] . ': ' . $row['title'] . '</a>'; } elseif ($type == "fu") { echo _Tkw("followups", $row['type']); } elseif ($type == "agenda") { echo _Tkw("appointments", $row['type']); } echo '</td>'; echo '<td align="right">' . format_time_interval_prefs($row['time']) . "</td>\n"; if ($meta_sum_billed) { echo '<td align="right">'; echo format_money($row['sumbilled']); echo "</td>\n"; } echo "</tr>\n"; } // Show total case hours echo "<tr>\n"; echo "<td><strong>" . _Ti('generic_input_total') . "</strong></td>\n"; echo "<td align='right'><strong>"; echo format_time_interval_prefs($total_time); echo "</strong></td>\n"; if ($meta_sum_billed) { echo '<td align="right"><strong>'; echo format_money($total_sum_billed); echo "</strong></td>\n"; } echo "</tr>\n"; echo "</table>\n"; echo "</p>\n"; }
function printGeneral($show_subtitle = true, $allow_edit = true) { // Read site configuration preferences $case_assignment_date = read_meta('case_assignment_date'); $case_alledged_crime = read_meta('case_alledged_crime'); $case_legal_reason = read_meta('case_legal_reason'); if ($show_subtitle) { show_page_subtitle(_T('generic_subtitle_general'), 'cases_intro'); } $add = allowed($this->data['case'], 'w'); $edit = allowed($this->data['case'], 'e'); $admin = allowed($this->data['case'], 'a'); // // Show various stages info // $q = "SELECT * FROM lcm_stage WHERE id_case = " . $this->data['case'] . " ORDER BY date_creation DESC"; $result = lcm_query($q); echo '<div style="float: right; width: 180px;">'; show_page_subtitle(_T('case_subtitle_stage'), 'cases_intro'); echo '<ul>'; while ($row = lcm_fetch_array($result)) { echo '<li>' . format_date($row['date_creation'], 'date_short') . ': <br/>' . _Tkw('stage', $row['kw_case_stage']) . '</li>'; } echo "</ul>\n"; echo "</div>\n"; // // Show case info // echo '<ul class="info">'; // Case ID echo '<li>' . '<span class="label1">' . _Ti('case_input_id') . '</span>' . '<span class="value1">' . show_case_id($this->getDataInt('id_case')) . '</span>' . "</li>\n"; // Case title echo '<li>' . '<span class="label1">' . _Ti('case_input_title') . '</span>' . '<span class="value1">' . $this->getDataString('title') . '</span>' . "</li>\n"; // Show users assigned to the case $q = "SELECT id_case, a.id_author, name_first, name_middle, name_last\n\t\t\t\tFROM lcm_case_author as ca, lcm_author as a\n\t\t\t\tWHERE (id_case=" . $this->getDataInt('id_case') . "\n\t\t\t\t AND ca.id_author = a.id_author)"; $authors_result = lcm_query($q); $cpt = 0; if (lcm_num_rows($authors_result) > 1) { echo '<li>' . '<span class="label2">' . _Ti('case_input_authors') . '</span>'; } else { echo '<li>' . '<span class="label2">' . _Ti('case_input_author') . '</span>'; } while ($author = lcm_fetch_array($authors_result)) { if ($cpt) { echo "; "; } $name = htmlspecialchars(get_person_name($author)); echo '<span class="value2">' . '<a href="author_det.php?author=' . $author['id_author'] . '" class="content_link"' . ' title="' . _T('case_tooltip_view_author_details', array('author' => $name)) . '">' . $name . "</a>" . '</span>'; if ($admin) { echo '<span class="noprint">'; echo ' <a href="edit_auth.php?case=' . $this->getDataInt('id_case') . '&author=' . $author['id_author'] . '"' . ' title="' . _T('case_tooltip_view_access_rights', array('author' => $name)) . '">' . '<img src="images/jimmac/stock_access_rights-16.png" width="16" height="16" border="0" alt="" />' . '</a>'; echo "</span>\n"; } $cpt++; } // [ML] FIXME Double-check if this is OK here in all scenarios if ($admin) { echo '<span class="noprint">'; echo '<a href="sel_auth.php?case=' . $this->getDataInt('id_case') . '" title="' . _T('add_user_case') . '">' . '<img src="images/jimmac/stock_attach-16.png" width="16" height="16" border="0" alt="' . _T('add_user_case') . '" />' . '</a>'; echo "</span>\n"; } echo "</li>\n"; echo '<li>' . '<span class="label2">' . _Ti('case_input_date_creation') . '</span>' . '<span class="value2">' . format_date($this->getDataString('date_creation')) . '</span>' . "</li>\n"; if ($case_assignment_date == 'yes') { // [ML] Case is assigned/unassigned when authors are added/remove // + case is auto-assigned when created. if ($this->data['date_assignment']) { echo '<li>' . '<span class="label2">' . _Ti('case_input_date_assigned') . '</span>' . '<span class="value2">' . format_date($this->getDataString('date_assignment')) . '</span>' . "</li>\n"; } } // Total time spent on case (redundant with "reports/times") $query = "SELECT " . lcm_query_sum_time('fu.date_start', 'fu.date_end') . " as time\n\t\t\t\t\tFROM lcm_followup as fu \n\t\t\t\t\tWHERE fu.id_case = " . $this->getDataInt('id_case', '__ASSERT__') . "\n\t\t\t\t\t AND fu.hidden = 'N'"; $result = lcm_query($query); $row_tmp = lcm_fetch_array($result); echo '<li>' . '<span class="label2">' . _Ti('case_input_total_time') . '</span>' . '<span class="value2">' . format_time_interval_prefs($row_tmp['time']) . ' ' . _T('time_info_short_hour') . '</span>' . "</li>\n"; if (substr($case_legal_reason, 0, 3) == 'yes') { echo '<li>' . '<span class="label2">' . _Ti('case_input_legal_reason') . '</span>' . '<span class="value2">' . clean_output($this->getDataString('legal_reason')) . '</span>' . "</li>\n"; } if (substr($case_alledged_crime, 0, 3) == 'yes') { echo '<li>' . '<span class="label2">' . _Ti('case_input_alledged_crime') . '</span>' . '<span class="value2">' . clean_output($this->getDataString('alledged_crime')) . '</span>' . "</li>\n"; } // Keywords show_all_keywords('case', $this->getDataInt('id_case')); if ($this->data['stage']) { // There should always be a stage, but in early versions, < 0.6.0, // it might have been missing, causing a lcm_panic(). $stage = get_kw_from_name('stage', $this->getDataString('stage', '__ASSERT__')); $id_stage = $stage['id_keyword']; show_all_keywords('stage', $this->getDataInt('id_case'), $id_stage); } // Notes echo '<li class="large">' . '<span class="label2">' . _Ti('case_input_notes') . '</span>' . '<span class="value2">' . nl2br($this->getDataString('notes')) . '</span>' . "</li>\n"; // echo "</ul>\n"; // echo "<p class='normal_text'>"; if ($allow_edit && $admin) { // Show case status (if closed, only site admin can re-open) echo '<li>'; echo "<form action='edit_fu.php' method='get'>\n"; echo "<input type='hidden' name='case' value='" . $this->getDataInt('id_case') . "' />\n"; echo _Ti('case_input_status'); echo "<select name='type' class='sel_frm' onchange='lcm_show(\"submit_status\")'>\n"; // in inc/inc_acc.php $statuses = get_possible_case_statuses($this->getDataString('status')); foreach ($statuses as $s => $futype) { $sel = $s == $this->getDataString('status') ? ' selected="selected"' : ''; echo '<option value="' . $futype . '"' . $sel . '>' . _T('case_status_option_' . $s) . "</option>\n"; } echo "</select>\n"; echo "<button type='submit' name='submit' id='submit_status' value='set_status' style='visibility: hidden;' class='simple_form_btn'>" . _T('button_validate') . "</button>\n"; echo "</form>\n"; // Show case stage echo "<form action='edit_fu.php' method='get'>\n"; echo "<input type='hidden' name='case' value='" . $this->getDataInt('id_case') . "' />\n"; echo "<input type='hidden' name='type' value='stage_change' />\n"; echo _Ti('case_input_stage'); echo "<select name='stage' class='sel_frm' onchange='lcm_show(\"submit_stage\")'>\n"; $stage_kws = get_keywords_in_group_name('stage'); foreach ($stage_kws as $kw) { $sel = $kw['name'] == $this->data['stage'] ? ' selected="selected"' : ''; echo "\t\t<option value='" . $kw['name'] . "'" . "{$sel}>" . _T(remove_number_prefix($kw['title'])) . "</option>\n"; } echo "</select>\n"; echo "<button type='submit' name='submit' id='submit_stage' value='set_stage' style='visibility: hidden;' class='simple_form_btn'>" . _T('button_validate') . "</button>\n"; echo "</form>\n"; echo "</li>\n"; } else { echo '<li>' . _Ti('case_input_status') . _T('case_status_option_' . $this->getDataString('status')) . "</li>\n"; echo '<li>' . _Ti('case_input_stage') . _Tkw('stage', $this->data['stage']) . "</li>\n"; } // If case closed, show conclusion if ($this->data['status'] == 'closed') { // get the last relevant conclusion $q_tmp = "SELECT * \n\t\t\t\tFROM lcm_followup\n\t\t\t\tWHERE id_case = " . $this->getDataInt('id_case') . "\n\t\t\t\tAND (type = 'conclusion'\n\t\t\t\t\t\tOR type = 'stage_change')\n\t\t\t\tORDER BY id_followup DESC \n\t\t\t\tLIMIT 1"; $r_tmp = lcm_query($q_tmp); $row_tmp = lcm_fetch_array($r_tmp); if ($row_tmp) { echo '<li>'; echo '<div style="background: #f0f0f0; padding: 4px; border: 1px solid #aaa;">'; echo _Ti('fu_input_conclusion'); echo get_fu_description($row_tmp, false); echo ' <a class="content_link" href="fu_det.php?followup=' . $row_tmp['id_followup'] . '">...</a>'; echo "</div>\n"; echo "</li>\n"; } } echo '<li>' . _Ti('case_input_collaboration'); echo "<ul style='padding-top: 1px; margin-top: 1px;'>"; echo "<li>" . _Ti('case_input_collaboration_read') . _T('info_' . ($this->getDataInt('public') ? 'yes' : 'no')) . "</li>\n"; echo "<li>" . _Ti('case_input_collaboration_write') . _T('info_' . ($this->getDataInt('pub_write') ? 'yes' : 'no')) . "</li>\n"; echo "</ul>\n"; echo "</li>\n"; echo "</ul>\n"; // clear the right column with stage info echo "<div style='clear: right;'></div>\n"; }