Example #1
0
            lcm_page_start(_T('title_fu_change_status'), '', '', 'cases_intro#status');
        }
    } else {
        lcm_page_start(_T('title_fu_new'), '', '', 'cases_followups');
    }
}
show_context_start();
show_context_case_title($case, 'followups');
show_context_case_involving($case);
// For 'change status' // FIXME (for edit existing fu?)
if ($_REQUEST['submit'] == 'set_status') {
    show_context_item(_Ti('fu_input_current_status') . _T('case_status_option_' . $row['status']));
}
// For 'change stage'
if (isset($old_stage) && $old_stage) {
    show_context_item(_Ti('fu_input_current_stage') . _Tkw('stage', $old_stage));
}
// Show stage information [ML] Not very efficient, I know, but I prefer to avoid spagetti
if ($_SESSION['form_data']['case_stage']) {
    // if editing an existing followup..
    $stage_info = get_kw_from_name('stage', $_SESSION['form_data']['case_stage']);
    $id_stage = $stage_info['id_keyword'];
    show_context_stage($case, $id_stage);
} elseif (isset($old_stage) && $old_stage) {
    // setting new stage
    $stage_info = get_kw_from_name('stage', $old_stage);
    $id_stage = $stage_info['id_keyword'];
    show_context_stage($case, $id_stage);
} else {
    // Normal follow-up
    $result = lcm_query("SELECT stage FROM lcm_case WHERE id_case = " . $case);
Example #2
0
 function printList()
 {
     global $prefs;
     // Select cases of which the current user is author
     $q = "SELECT e.id_expense, e.id_case, e.id_author, e.status, e.type, \n\t\t\t\te.description, e.date_creation, e.date_update, e.pub_read,\n\t\t\t\te.pub_write, a.name_first, a.name_middle, a.name_last,\n\t\t\t\tcount(ec.id_expense) as nb_comments, c.title as case_title\n\t\t\tFROM lcm_expense as e\n\t\t\tLEFT JOIN lcm_expense_comment as ec ON (ec.id_expense = e.id_expense)\n\t\t\tLEFT JOIN lcm_author as a ON (a.id_author = e.id_author) \n\t\t\tLEFT JOIN lcm_case as c ON (c.id_case = e.id_case) ";
     $q .= " WHERE (1=1 ";
     if ($this->search) {
         $q .= " AND (";
         if (is_numeric($this->search)) {
             $q .= " e.id_expense = " . $this->search . " OR ";
         }
         $q .= " e.description LIKE '%" . $this->search . "%' ";
         $q .= " )";
     }
     if ($this->id_case) {
         $q .= " AND e.id_case = " . $this->id_case;
     }
     $q .= ")";
     //
     // Apply filters to SQL
     //
     // Case owner TODO
     // $q .= " AND " . $q_owner;
     // Period (date_creation) to show
     if ($prefs['case_period'] < 1900) {
         // since X days
         // $q .= " AND TO_DAYS(NOW()) - TO_DAYS(date_creation) < " . $prefs['case_period'];
         $q .= " AND " . lcm_query_subst_time('e.date_creation', 'NOW()') . ' < ' . $prefs['case_period'] * 3600 * 24;
     } else {
         // for year X
         $q .= " AND " . lcm_query_trunc_field('e.date_creation', 'year') . ' = ' . $prefs['case_period'];
     }
     $q .= " GROUP BY e.id_expense, e.id_case, e.id_author, e.status, e.type, e.description, e.date_creation, e.date_update, e.pub_read, e.pub_write, a.name_first, a.name_middle, a.name_last, c.title ";
     //
     // Sort
     //
     $sort_clauses = array();
     $sort_allow = array('ASC' => 1, 'DESC' => 1);
     // Sort by request type
     if ($sort_allow[_request('type_order')]) {
         $sort_clauses[] = "type " . _request('type_order');
     }
     if ($sort_allow[_request('status_order')]) {
         $sort_clauses[] = "status " . _request('status_order');
     }
     // Sort cases by creation or update date
     if ($sort_allow[_request('date_order')]) {
         $sort_clauses[] = "date_creation " . _request('date_order');
     } elseif ($sort_allow[_request('upddate_order')]) {
         $sort_clauses[] = "date_update " . _request('upddate_order');
     }
     if (count($sort_clauses)) {
         $q .= " ORDER BY " . implode(', ', $sort_clauses);
     } else {
         $q .= " ORDER BY date_creation DESC";
     }
     // default sort
     $result = lcm_query($q);
     // Check for correct start position of the list
     $this->number_of_rows = lcm_num_rows($result);
     if ($this->list_pos >= $this->number_of_rows) {
         $this->list_pos = 0;
     }
     // Position to the page info start
     if ($this->list_pos > 0) {
         if (!lcm_data_seek($result, $this->list_pos)) {
             lcm_panic("Error seeking position " . $this->list_pos . " in the result");
         }
     }
     for ($i = 0; $i < $prefs['page_rows'] && ($row = lcm_fetch_array($result)); $i++) {
         $css = $i % 2 ? "dark" : "light";
         echo "<tr>\n";
         // Expense ID
         echo "<td class='tbl_cont_" . $css . "'>";
         echo highlight_matches($row['id_expense'], $this->search);
         echo "</td>\n";
         // Author
         echo "<td class='tbl_cont_" . $css . "'>";
         echo get_person_initials($row);
         echo "</td>\n";
         // Attached to case..
         echo "<td class='tbl_cont_" . $css . "'>";
         if ($row['id_case']) {
             echo '<abbr title="' . $row['case_title'] . '">' . $row['id_case'] . '</a>';
         }
         echo "</td>\n";
         // Date creation
         echo "<td class='tbl_cont_" . $css . "'>";
         echo format_date($row['date_creation'], 'short');
         echo "</td>\n";
         // Type
         echo "<td class='tbl_cont_" . $css . "'>";
         echo _Tkw('_exptypes', $row['type']);
         echo "</td>\n";
         // Description
         global $fu_desc_len;
         // configure via my_options.php with $GLOBALS['fu_desc_len'] = NNN;
         $more_desc = _request('more_desc', 0);
         $desc_length = isset($fu_desc_len) && $fu_desc_len > 0 ? $fu_desc_len : 256;
         $description = $row['description'];
         if ($more_desc || strlen(lcm_utf8_decode($row['description'])) < $desc_length) {
             $description = $row['description'];
         } else {
             $description = substr($row['description'], 0, $desc_length) . '...';
         }
         echo "<td class='tbl_cont_" . $css . "'>";
         echo '<a class="content_link" href="exp_det.php?expense=' . $row['id_expense'] . '">';
         echo nl2br(highlight_matches($description, $this->search));
         echo "</a>";
         echo "</td>\n";
         // # Comments
         echo "<td class='tbl_cont_" . $css . "'>";
         echo $row['nb_comments'];
         echo "</td>\n";
         // Date update
         echo "<td class='tbl_cont_" . $css . "'>";
         if ($row['date_update'] != $row['date_creation']) {
             echo format_date($row['date_update'], 'short');
         }
         echo "</td>\n";
         // Status
         echo "<td class='tbl_cont_" . $css . "'>";
         echo _T('expense_status_option_' . $row['status']);
         echo "</td>\n";
         echo "</tr>\n";
     }
 }
Example #3
0
function show_report_filters($id_report, $is_runtime = false)
{
    // Get general report info
    $q = "SELECT * FROM lcm_report WHERE id_report = " . intval($id_report);
    $res = lcm_query($q);
    $rep_info = lcm_fetch_array($res);
    if (!$rep_info) {
        lcm_panic("Report does not exist: {$id_report}");
    }
    // List filters attached to this report
    $query = "SELECT *\n\t\tFROM lcm_rep_filter as v, lcm_fields as f\n\t\tWHERE id_report = " . $id_report . "\n\t\tAND f.id_field = v.id_field";
    // If generating the report (as opposed to editing), show filters
    // who have a filter type (eq, neq, in, ..), but no value.
    if ($is_runtime) {
        $query .= " AND v.type != '' AND v.value = '' ";
    }
    $result = lcm_query($query);
    if (lcm_num_rows($result)) {
        if ($is_runtime) {
            // submit all at once (else submit on a per-filter basis)
            echo '<form action="run_rep.php" name="frm_filters" method="get">' . "\n";
            echo '<input name="rep" value="' . $id_report . '" type="hidden" />' . "\n";
            if (isset($_REQUEST['export'])) {
                echo '<input name="export" value="' . $_REQUEST['export'] . '" type="hidden" />' . "\n";
            }
        }
        echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
        while ($filter = lcm_fetch_array($result)) {
            if (!$is_runtime) {
                echo "<form action='upd_rep_field.php' name='frm_line_additem' method='get'>\n";
                echo "<input name='update' value='filter' type='hidden' />\n";
                echo "<input name='rep' value='{$id_report}' type='hidden' />\n";
                echo "<input name='id_filter' value='" . $filter['id_filter'] . "' type='hidden' />\n";
            }
            echo "<tr>\n";
            echo "<td>" . _Th($filter['description']) . "</td>\n";
            // Type of filter
            echo "<td>";
            $all_filters = array('number' => array('none', 'num_eq', 'num_neq', 'num_lt', 'num_le', 'num_gt', 'num_ge'), 'date' => array('none', 'date_eq', 'date_in', 'date_lt', 'date_le', 'date_gt', 'date_ge'), 'text' => array('none', 'text_eq', 'text_neq'));
            if ($all_filters[$filter['filter']]) {
                // At runtime, if a filter has been selected, do not allow select
                if ($filter['type'] && $is_runtime) {
                    echo _T('rep_filter_' . $filter['type']);
                } else {
                    echo "<select name='filter_type'>\n";
                    echo "<option value=''>...</option>\n";
                    foreach ($all_filters[$filter['filter']] as $f) {
                        $sel = $filter['type'] == $f ? ' selected="selected"' : '';
                        echo "<option value='" . $f . "'" . $sel . ">" . _T('rep_filter_' . $f) . "</option>\n";
                    }
                    echo "</select>\n";
                }
            } else {
                // XXX Should happen only if a filter was removed in a future version, e.g. rarely
                // or between development releases.
                echo "Unknown filter";
            }
            echo "</td>\n";
            // Value for filter
            echo "<td>";
            switch ($filter['type']) {
                case 'num_eq':
                case 'num_neq':
                    if ($filter['field_name'] == 'id_author') {
                        $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
                        // XXX make this a function
                        $q = "SELECT * FROM lcm_author WHERE status IN ('admin', 'normal', 'external')";
                        $result_author = lcm_query($q);
                        echo "<select name='{$name}'>\n";
                        echo "<option value=''>...</option>\n";
                        // TRAD
                        while ($author = lcm_fetch_array($result_author)) {
                            // Check for already submitted value
                            $sel = $filter['value'] == $author['id_author'] || $_REQUEST['filter_val' . $filter['id_filter']] == $author['id_author'] ? ' selected="selected"' : '';
                            echo "<option value='" . $author['id_author'] . "'" . $sel . ">" . $author['id_author'] . " : " . get_person_name($author) . "</option>\n";
                        }
                        echo "</select>\n";
                        break;
                    }
                case 'num_lt':
                case 'num_gt':
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
                    echo '<input style="width: 99%;" type="text" name="' . $name . '" value="' . $filter['value'] . '" />';
                    break;
                case 'date_eq':
                case 'date_lt':
                case 'date_le':
                case 'date_gt':
                case 'date_ge':
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'date';
                    echo get_date_inputs($name, $filter['value']);
                    // FIXME
                    break;
                case 'date_in':
                    // date_in has two values, stored ex: 2005-01-01 00:00:00;2006-02-02 00:00:00
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'date';
                    $values = split(";", $filter['value']);
                    echo get_date_inputs($name . '_start', $values[0]);
                    echo "<br />\n";
                    echo get_date_inputs($name . '_end', $values[1]);
                    break;
                case 'text_eq':
                case 'text_neq':
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
                    if ($filter['enum_type']) {
                        $enum = explode(":", $filter['enum_type']);
                        if ($enum[0] == 'keyword') {
                            if ($enum[1] == 'system_kwg') {
                                $all_kw = get_keywords_in_group_name($enum[2]);
                                echo '<select name="' . $name . '">' . "\n";
                                echo '<option value="">' . "..." . "</option>\n";
                                // TRAD
                                foreach ($all_kw as $kw) {
                                    $sel = $filter['value'] == $kw['name'] || $_REQUEST['filter_val' . $filter['id_filter']] == $kw['name'] ? ' selected="selected" ' : '';
                                    echo '<option value="' . $kw['name'] . '"' . $sel . '>' . _Tkw($enum[2], $kw['name']) . "</option>\n";
                                }
                                echo "</select>\n";
                            }
                        } elseif ($enum[0] == 'list') {
                            $items = split(",", $enum[1]);
                            echo '<select name="' . $name . '">' . "\n";
                            echo '<option value="">' . "..." . "</option>\n";
                            // TRAD
                            foreach ($items as $i) {
                                $tmp = $i;
                                if ($enum[2]) {
                                    $tmp = _T($enum[2] . $tmp);
                                }
                                $sel = $filter['value'] == $i || $_REQUEST['filter_val' . $filter['id_filter']] == $i ? ' selected="selected" ' : '';
                                echo '<option value="' . $i . '"' . $sel . '>' . $tmp . "</option>\n";
                            }
                            echo "</select>\n";
                        }
                    } else {
                        echo '<input style="width: 99%;" type="text" name="' . $name . '" value="' . $filter['value'] . '" />';
                    }
                    break;
                default:
                    echo "<!-- no type -->\n";
            }
            echo "</td>\n";
            if (!$is_runtime) {
                // Button to validate
                echo "<td>";
                echo "<button class='simple_form_btn' name='validate_filter_addfield'>" . _T('button_validate') . "</button>\n";
                echo "</td>\n";
                // Link for "Remove"
                echo "<td><a class='content_link' href='upd_rep_field.php?rep=" . $id_report . "&amp;" . "remove=filter" . "&amp;" . "id_filter=" . $filter['id_filter'] . "'>" . "X" . "</a></td>\n";
            }
            echo "</tr>\n";
            if (!$is_runtime) {
                echo "</form>\n";
            }
        }
        echo "</table>\n";
    }
    if ($is_runtime) {
        echo "<p><button class='simple_form_btn' name='validate_filter_addfield'>" . _T('button_validate') . "</button></p>\n";
        echo "</form>\n";
        return;
    }
    // List all available fields in selected tables for report
    $query = "SELECT *\n\t\tFROM lcm_fields\n\t\tWHERE ";
    $sources = array();
    if ($rep_info['line_src_name']) {
        array_push($sources, "'lcm_" . $rep_info['line_src_name'] . "'");
    }
    // Fetch all tables available as rep colums
    // (this is not like rep line, because the source is not always in
    // lcm_report, but this should be 'fixed')
    $q_tmp = "SELECT DISTINCT table_name \n\t\t\t\tFROM lcm_rep_col as rp, lcm_fields as f\n\t\t\t\tWHERE rp.id_field = f.id_field\n\t\t\t\t  AND rp.id_report = " . $id_report;
    $result_tmp = lcm_query($q_tmp);
    while ($row = lcm_fetch_array($result_tmp)) {
        array_push($sources, "'" . $row['table_name'] . "'");
    }
    // Fetch all keyword sources
    if ($rep_info['col_src_type'] == 'keyword' && $rep_info['col_src_name']) {
        $kwg = get_kwg_from_name($rep_info['col_src_name']);
        if ($kwg['type'] == 'system') {
            switch ($kwg['name']) {
            }
        } else {
            if ($kwg['type'] == 'client_org') {
                array_push($sources, "'lcm_client'");
                array_push($sources, "'lcm_org'");
            } else {
                array_push($sources, "'lcm_" . $kwg['type'] . "'");
            }
        }
    }
    // If lcm_case in there, also add lcm_stage
    $tmp = '';
    foreach ($sources as $s) {
        if ($s == "'lcm_case'") {
            $tmp = "lcm_stage";
        }
    }
    if ($tmp) {
        array_push($sources, "'lcm_stage'");
    }
    // List only filters if table were selected as sources (line/col)
    if (count($sources)) {
        $query .= " table_name IN ( " . implode(" , ", $sources) . " ) AND ";
        $query .= " filter != 'none'";
        $query .= " ORDER BY table_name ";
        echo "<!-- QUERY: {$query} -->\n";
        $result = lcm_query($query);
        if (lcm_num_rows($result)) {
            echo "<form action='upd_rep_field.php' name='frm_line_additem' method='get'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo "<input name='add' value='filter' type='hidden' />\n";
            echo "<p class='normal_text'>" . _Ti('rep_input_filter_add');
            echo "<select name='id_field'>\n";
            echo "<option value=''>...</option>\n";
            while ($row = lcm_fetch_array($result)) {
                echo "<option value='" . $row['id_field'] . "'>" . _Ti('rep_info_table_' . $row['table_name']) . _Th($row['description']) . "</option>\n";
            }
            echo "</select>\n";
            echo "<button class='simple_form_btn' name='validate_filter_addfield'>" . _T('button_validate') . "</button>\n";
            echo "</p>\n";
            echo "</form>\n";
        }
    } else {
        echo '<p class="normal_text">' . _T('rep_info_select_source_first') . "</p>\n";
    }
}
Example #4
0
 function printGeneral($show_subtitle = true)
 {
     $meta_citizen_number = read_meta('client_citizen_number');
     $meta_civil_status = read_meta('client_civil_status');
     $meta_income = read_meta('client_income');
     $meta_date_birth = read_meta('client_date_birth');
     if ($show_subtitle) {
         show_page_subtitle(_T('generic_subtitle_general'), 'clients_intro');
     }
     echo '<ul class="info">';
     echo '<li>' . '<span class="label1">' . _Ti('client_input_id') . '</span>' . '<span class="value1">' . $this->getDataInt('id_client') . '</span>' . "</li>\n";
     echo '<li>' . '<span class="label1">' . _Ti('person_input_name') . '</span>' . '<span class="value1">' . $this->getName() . '</span>' . "</li>\n";
     if ($this->data['gender'] == 'male' || $this->getDataString('gender') == 'female') {
         $gender = _T('person_input_gender_' . $this->getDataString('gender'));
     } else {
         $gender = _T('info_not_available');
     }
     if (substr($meta_date_birth, 0, 3) == 'yes') {
         echo "<li>" . _Ti('person_input_date_birth');
         if ($birth = $this->getDataString('data_birth')) {
             echo format_date($birth) . " (" . _T('person_info_years_old', array('years' => years_diff($this->getDataString('date_birth')))) . ")";
         } else {
             echo _T('info_not_available');
         }
         echo "</li>\n";
     }
     echo '<li>' . '<span class="label1">' . _Ti('person_input_gender') . '</span>' . '<span class="value1">' . $gender . '</span>' . "</li>\n";
     if (substr($meta_citizen_number, 0, 3) == 'yes') {
         echo '<li>' . '<span class="label2">' . _Ti('person_input_citizen_number') . '</span>' . '<span class="value2">' . clean_output($this->getDataString('citizen_number')) . '</span>' . "</li>\n";
     }
     if (substr($meta_civil_status, 0, 3) == 'yes') {
         // [ML] Patch for bug #1372138 (LCM < 0.6.4)
         $civil_status = $this->getDataString('civil_status', 'unknown');
         echo '<li>' . '<span class="label2">' . _Ti('person_input_civil_status') . '</span>' . '<span class="value2">' . _Tkw('civilstatus', $civil_status) . '</span>' . "</li>\n";
     }
     if (substr($meta_income, 0, 3) == 'yes') {
         // [ML] Patch for bug #1372138 (LCM < 0.6.4)
         $income = $this->getDataString('income', 'unknown');
         echo '<li>' . '<span class="label2">' . _Ti('person_input_income') . '</span>' . '<span class="value2">' . _Tkw('income', $income) . '</span>' . "</li>\n";
     }
     show_all_keywords('client', $this->getDataInt('id_client'));
     echo '<li>' . '<span class="label2">' . _Ti('case_input_date_creation') . '</span>' . '<span class="value2">' . format_date($this->getDataString('date_creation')) . '</span>' . "</li>\n";
     echo '<li class="large">' . '<span class="label2">' . _Ti('client_input_notes') . '</span>' . '<span class="value2">' . nl2br(clean_output($this->getDataString('notes'))) . '</span>' . "</li>\n";
     echo "</ul>\n";
     // Show client contacts (if any)
     show_all_contacts('client', $this->getDataInt('id_client'));
 }
Example #5
0
 function printEdit()
 {
     global $prefs;
     $admin = allowed($this->getDataInt('id_case'), 'a');
     // FIXME
     $edit = allowed($this->getDataInt('id_case'), 'e');
     // FIXME
     $write = allowed($this->getDataInt('id_case'), 'w');
     // FIXME (put in constructor)
     // FIXME: not sure whether this works as previously
     $dis = isDisabled(!($admin || $edit));
     echo '<table class="tbl_usr_dtl" width="99%">' . "\n";
     echo '<tr><td>';
     echo f_err_star('date_start') . _T('fu_input_date_start');
     echo "</td>\n";
     echo "<td>";
     $name = $admin || $edit ? 'start' : '';
     echo get_date_inputs($name, $this->data['date_start'], false);
     echo ' ' . _T('time_input_time_at') . ' ';
     echo get_time_inputs($name, $this->data['date_start']);
     echo "</td>\n";
     echo "</tr>\n";
     echo "<tr><td>";
     echo f_err_star('date_end') . ($prefs['time_intervals'] == 'absolute' ? _T('fu_input_date_end') : _T('fu_input_time_length'));
     echo "</td>\n";
     echo '<td>';
     if ($prefs['time_intervals'] == 'absolute') {
         // Buggy code, so isolated most important cases
         if ($this->data['id_followup'] == 0) {
             $name = 'end';
         } elseif ($edit) {
             $name = 'end';
         } else {
             // user can 'finish' entering data
             $name = $admin || $edit && $this->data['date_end'] == '0000-00-00 00:00:00' ? 'end' : '';
         }
         echo get_date_inputs($name, $this->data['date_end']);
         echo ' ';
         echo _T('time_input_time_at') . ' ';
         echo get_time_inputs($name, $this->data['date_end']);
     } else {
         $name = '';
         // Buggy code, so isolated most important cases
         if ($this->getDataInt('id_followup') == 0) {
             $name = 'delta';
         } elseif ($edit) {
             $name = 'delta';
         } else {
             // user can 'finish' entering data
             $name = $admin || $edit && $this->getDataString('date_end') == '0000-00-00 00:00:00' ? 'delta' : '';
         }
         if (empty($_SESSION['errors'])) {
             $interval = $this->getDataString('date_end') != '0000-00-00 00:00:00' ? strtotime($this->getDataString('date_end')) - strtotime($this->getDataString('date_start')) : 0;
             echo get_time_interval_inputs($name, $interval);
         } else {
             echo get_time_interval_inputs_from_array($name, $this->data);
         }
     }
     echo "</td>\n";
     echo "</tr>\n";
     // Show 'conclusion' options
     if ($this->show_conclusion) {
         $kws_conclusion = get_keywords_in_group_name('conclusion');
         $kws_result = get_keywords_in_group_name('_crimresults');
         echo "<tr>\n";
         echo "<td>" . _Ti('fu_input_conclusion') . "</td>\n";
         echo '<td>';
         // Result
         if (read_meta('case_result') == 'yes') {
             echo '<select ' . $dis . ' name="result" size="1" class="sel_frm">' . "\n";
             $default = '';
             if ($this->data['result']) {
                 $default = $this->data['result'];
             }
             foreach ($kws_result as $kw) {
                 $sel = isSelected($kw['name'] == $default);
                 echo '<option ' . $sel . ' value="' . $kw['name'] . '">' . _T(remove_number_prefix($kw['title'])) . "</option>\n";
             }
             echo "</select><br/>\n";
         }
         // Conclusion
         echo '<select ' . $dis . ' name="conclusion" size="1" class="sel_frm">' . "\n";
         $default = '';
         if ($this->data['conclusion']) {
             $default = $this->data['conclusion'];
         }
         foreach ($kws_conclusion as $kw) {
             $sel = isSelected($kw['name'] == $default);
             echo '<option ' . $sel . ' value="' . $kw['name'] . '">' . _T(remove_number_prefix($kw['title'])) . "</option>\n";
         }
         echo "</select>\n";
         echo "</td>\n";
         echo "</tr>\n";
         // If guilty, what sentence?
         $kws_sentence = get_keywords_in_group_name('sentence');
         echo "<tr>\n";
         echo "<td>" . _Ti('fu_input_sentence') . "</td>\n";
         echo '<td>';
         echo '<select ' . $dis . ' name="sentence" size="1" class="sel_frm">' . "\n";
         $default = '';
         if ($this->data['sentence']) {
             $default = $this->data['sentence'];
         }
         echo "<!-- " . $default . " -->\n";
         foreach ($kws_sentence as $kw) {
             $sel = $kw['name'] == $default ? ' selected="selected"' : '';
             echo '<option ' . $sel . ' value="' . $kw['name'] . '">' . _T(remove_number_prefix($kw['title']), array('currency' => read_meta('currency'))) . "</option>\n";
         }
         echo "</select>\n";
         // If sentence, for how much?
         echo '<input type="text" name="sentence_val" size="10" value="' . $this->data['sentence_val'] . '" />';
         echo "</td>\n";
         echo "</tr>\n";
     }
     if (_request('submit') == 'set_status' || is_status_change($this->getDataString('type'))) {
         // Change status
         echo "<tr>\n";
         echo "<td>" . _T('case_input_status') . "</td>\n";
         echo "<td>";
         echo '<input type="hidden" name="type" value="' . $this->getDataString('type') . '" />' . "\n";
         echo _T('kw_followups_' . $this->data['type'] . '_title');
         echo "</td>\n";
         echo "</tr>\n";
     } elseif (_request('submit') == 'set_stage' || $this->getDataString('type') == 'stage_change') {
         // Change stage
         echo "<tr>\n";
         echo "<td>" . _T('fu_input_next_stage') . "</td>\n";
         echo "<td>";
         echo '<input type="hidden" name="type" value="' . $this->getDataString('type') . '" />' . "\n";
         // This is to compensate an old bug, when 'case stage' was not stored in fu.description
         // and therefore editing a follow-up would not give correct information.
         // Bug was in CVS of 0.4.3 between 19-20 April 2005. Should not affect many people.
         if ($s = $this->getDataString('new_stage')) {
             echo '<input type="hidden" name="new_stage" value="' . $s . '" />' . "\n";
             echo _Tkw('stage', $s);
         } else {
             echo "New stage information not available";
         }
         echo "</td>\n";
         echo "</tr>\n";
         if ($s = $this->getDataString('new_stage')) {
             // Update stage keywords (if any)
             $stage = get_kw_from_name('stage', $s);
             $id_stage = $stage['id_keyword'];
             show_edit_keywords_form('stage', $this->data['id_case'], $id_stage);
         }
     } elseif ($this->getDataString('type') == 'assignment' || $this->getDataString('type') == 'unassignment') {
         // Do not allow assignment/un-assignment follow-ups to be changed
         echo "<tr>\n";
         echo "<td>" . _T('fu_input_next_stage') . "</td>\n";
         echo "<td>";
         echo '<input type="hidden" name="type" value="' . $this->getDataString('type') . '" />' . "\n";
         echo _Tkw('followups', $this->getDataString('type'));
         echo "</td>\n";
         echo "</tr>\n";
     } else {
         // The usual follow-up
         echo "<tr>\n";
         echo "<td>" . _T('fu_input_type') . "</td>\n";
         echo "<td>";
         echo '<select ' . $dis . ' name="type" size="1" class="sel_frm">' . "\n";
         $default_fu = get_suggest_in_group_name('followups');
         $futype_kws = get_keywords_in_group_name('followups');
         $kw_found = false;
         foreach ($futype_kws as $kw) {
             $sel = isSelected($kw['name'] == $default_fu);
             if ($sel) {
                 $kw_found = true;
             }
             echo '<option value="' . $kw['name'] . '"' . $sel . '>' . _T(remove_number_prefix($kw['title'])) . "</option>\n";
         }
         // Exotic case where the FU keyword was hidden by the administrator,
         // but an old follow-up using that keyword is being edited.
         if (!$kw_found) {
             echo '<option selected="selected" value="' . $default_fu . '">' . _Tkw('followups', $default_fu) . "</option>\n";
         }
         echo "</select>\n";
         echo "</td>\n";
         echo "</tr>\n";
     }
     // Keywords (if any)
     show_edit_keywords_form('followup', $this->getDataInt('id_followup'));
     // Description
     echo "<tr>\n";
     echo '<td valign="top">' . f_err_star('description') . _T('fu_input_description') . "</td>\n";
     echo '<td>';
     if ($this->getDataString('type') == 'assignment' || $this->getDataString('type') == 'unassignment') {
         // Do not allow edit of assignment
         echo '<input type="hidden" name="description" value="' . $this->getDataString('description') . '" />' . "\n";
         echo get_fu_description($this->data);
     } else {
         echo '<textarea ' . $dis . ' name="description" rows="15" cols="60" class="frm_tarea">';
         echo clean_output($this->getDataString('description'));
         echo "</textarea>";
     }
     echo "</td></tr>\n";
     // Sum billed field
     if ($this->show_sum_billed == "yes") {
         echo '<tr>';
         echo '<td>' . _T('fu_input_sum_billed') . "</td>\n";
         echo '<td>';
         echo '<input ' . $dis . ' name="sumbilled" ' . 'value="' . clean_output($this->getDataString('sumbilled')) . '" ' . 'class="search_form_txt" size="10" />';
         // [ML] If we do this we may as well make a function
         // out of it, but not sure where to place it :-)
         // This code is also in config_site.php
         $currency = read_meta('currency');
         if (empty($currency)) {
             $current_lang = $GLOBALS['lang'];
             $GLOBALS['lang'] = read_meta('default_language');
             $currency = _T('currency_default_format');
             $GLOBALS['lang'] = $current_lang;
         }
         echo htmlspecialchars($currency);
         echo "</td></tr>\n";
     }
     echo "</table>\n\n";
     // XXX FIXME: Should probably be in some function "is_system_fu"
     // or even "is_deletable"
     if ($this->getDataInt('id_followup') && allowed($this->data['id_case'], 'a') && !(is_status_change($this->data['type']) || $this->data['type'] == 'assignment' || $this->data['type'] == 'unassignment')) {
         $checked = $this->getDataString('hidden') == 'Y' ? ' checked="checked" ' : '';
         echo '<p class="normal_text">';
         echo '<input type="checkbox"' . $checked . ' name="delete" id="box_delete" />';
         echo '<label for="box_delete">' . _T('fu_info_delete') . '</label>';
         echo "</p>\n";
     }
     // Add followup appointment
     if (!_request('followup')) {
         echo "<!-- Add appointment? -->\n";
         echo '<p class="normal_text">';
         echo '<input type="checkbox" name="add_appointment" id="box_new_app" onclick="display_block(\'new_app\', \'flip\')" />';
         echo '<label for="box_new_app">' . _T('fu_info_add_future_activity') . '</label>';
         echo "</p>\n";
         echo '<div id="new_app" style="display: none;">';
         echo '<table class="tbl_usr_dtl" width="99%">' . "\n";
         echo "<!-- Start time -->\n\t\t<tr><td>";
         echo _T('time_input_date_start');
         echo "</td><td>";
         echo get_date_inputs('app_start', $this->data['app_start_time'], false);
         echo ' ' . _T('time_input_time_at') . ' ';
         echo get_time_inputs('app_start', $this->data['app_start_time']);
         echo f_err_star('app_start_time');
         echo "</td></tr>\n";
         echo "<!-- End time -->\n\t\t<tr><td>";
         echo $prefs['time_intervals'] == 'absolute' ? _T('time_input_date_end') : _T('app_input_time_length');
         echo "</td><td>";
         if ($prefs['time_intervals'] == 'absolute') {
             echo get_date_inputs('app_end', $this->data['app_end_time']);
             echo ' ' . _T('time_input_time_at') . ' ';
             echo get_time_inputs('app_end', $this->data['app_end_time']);
             echo f_err_star('app_end_time');
         } else {
             $interval = $this->data['app_end_time'] != '0000-00-00 00:00:00' ? strtotime($this->data['app_end_time']) - strtotime($this->data['app_start_time']) : 0;
             //	echo _T('calendar_info_time') . ' ';
             echo get_time_interval_inputs('app_delta', $interval);
             echo f_err_star('app_end_time');
         }
         echo "</td></tr>\n";
         /* [ML] Removing, not useful for now
         			   echo "<!-- Reminder -->\n\t\t<tr><td>";
         			   echo (($prefs['time_intervals'] == 'absolute') ? _T('app_input_reminder_time') : _T('app_input_reminder_offset'));
         			   echo "</td><td>";
         			   if ($prefs['time_intervals'] == 'absolute') {
         			   echo get_date_inputs('app_reminder', $this->data['app_reminder']);
         			   echo ' ' . _T('time_input_time_at') . ' ';
         			   echo get_time_inputs('app_reminder', $this->data['app_reminder']);
         			   echo f_err_star('app_reminder');
         			   } else {
         			   $interval = ( ($this->data['app_end_time']!='0000-00-00 00:00:00') ?
         			   strtotime($this->data['app_start_time']) - strtotime($this->data['app_reminder']) : 0);
         			//	echo _T('calendar_info_time') . ' ';
         			echo get_time_interval_inputs('app_rem_offset', $interval);
         			echo " " . _T('time_info_before_start');
         			echo f_err_star('app_reminder');
         			}
         			echo "</td></tr>\n";
         			 */
         // TODO: [ML] a bit of testing to see if this survives an error on new case
         // I suspect it doesn't..
         echo "<!-- Appointment title -->\n\t\t<tr><td>";
         echo f_err_star('app_title') . _T('app_input_title');
         echo "</td><td>";
         echo '<input type="text" ' . $dis . ' name="app_title" size="50" value="';
         echo clean_output($this->getDataString('app_title')) . '" class="search_form_txt" />';
         echo "</td></tr>\n";
         echo "<!-- Appointment type -->\n\t\t<tr><td>";
         echo _T('app_input_type');
         echo "</td><td>";
         echo '<select ' . $dis . ' name="app_type" size="1" class="sel_frm">';
         global $system_kwg;
         if ($_SESSION['fu_app_data']['type']) {
             $default_app = $_SESSION['fu_app_data']['type'];
         } else {
             $app_kwg = get_kwg_from_name('appointments');
             $default_app = $app_kwg['suggest'];
         }
         $opts = array();
         foreach ($system_kwg['appointments']['keywords'] as $kw) {
             $opts[$kw['name']] = _T(remove_number_prefix($kw['title']));
         }
         asort($opts);
         foreach ($opts as $k => $opt) {
             $sel = isSelected($k == $default_app);
             echo "<option value='{$k}'{$sel}>{$opt}</option>\n";
         }
         echo '</select>';
         echo "</td></tr>\n";
         echo "<!-- Appointment description -->\n";
         echo "<tr><td valign=\"top\">";
         echo _T('app_input_description');
         echo "</td><td>";
         echo '<textarea ' . $dis . ' name="app_description" rows="5" cols="60" class="frm_tarea">';
         echo clean_output($this->getDataString('app_description'));
         echo '</textarea>';
         echo "</td></tr>\n";
         echo "</table>\n";
         echo "</div>\n";
     }
 }
Example #6
0
     echo "</td>\n";
 }
 if ($show_more_times) {
     $fu_types = get_keywords_in_group_name('followups', false);
     $html = "";
     foreach ($fu_types as $f) {
         $q2 = "SELECT type,\n\t\t\t\t\t\t\t\t\tsum(IF(UNIX_TIMESTAMP(fu.date_end) > 0,\n\t\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\t\tsum(sumbilled) as sumbilled\n\t\t\t\t\t\t\t\tFROM  lcm_followup as fu\n\t\t\t\t\t\t\t\tWHERE fu.id_case = {$case}\n\t\t\t\t\t\t\t\t  AND fu.id_author = " . $row['id_author'] . "\n\t\t\t\t\t\t\t\t  AND fu.hidden = 'N'\n\t\t\t\t\t\t\t\t  AND fu.type = '" . $f['name'] . "'\n\t\t\t\t\t\t\t\tGROUP BY fu.type";
         $r2 = lcm_query($q2);
         // FIXME: css for "ul/li" is a bit weird, but without specifying the height,
         // the text is displayed under the line...
         // But we should probably scrap the whole table anyway
         while ($row2 = lcm_fetch_array($r2)) {
             // either:  futype (70%) + length (15%) + sumbilled (15%)
             // or only: futype (70%) + length (30%)
             $html .= "<li style='clear: both; height: 1.4em; width: 100%;'>";
             $html .= '<div style="float: left; text-align: left;">' . _Tkw('followups', $row2['type']) . ": " . '</div>';
             if ($meta_sum_billed == 'yes') {
                 $html .= '<div style="width: 120px; float: right; text-align: right;">' . format_money($row2['sumbilled']) . '</div>';
             }
             $html .= '<div style="width: 120px; float: right; text-align: right;">' . format_time_interval_prefs($row2['time']) . '</div>';
             $html .= "</li>\n";
         }
     }
     if ($html) {
         echo "</tr>\n";
         echo "<tr>";
         if ($meta_sum_billed == 'yes') {
             echo "<td colspan='3'>";
         } else {
             echo "<td colspan='2'>";
         }
Example #7
0
function get_fu_description($item, $make_short = true)
{
    if (!is_array($item)) {
        lcm_debug("get_fu_description: parameter is not an array.");
        return '';
    }
    global $prefs;
    global $fu_desc_len;
    // configure via my_options.php with $GLOBALS['fu_desc_len'] = NNN;
    $short_description = '';
    // Set the length of short followup title (was: wide = 48, narrow = 115)
    $title_length = isset($fu_desc_len) && $fu_desc_len > 0 ? $fu_desc_len : 256;
    if ($item['type'] == 'assignment' && is_numeric($item['description'])) {
        $res1 = lcm_query("SELECT * FROM lcm_author WHERE id_author = " . $item['description']);
        $author1 = lcm_fetch_array($res1);
        $short_description = _T('case_info_author_assigned', array('name' => get_person_name($author1)));
    } elseif ($item['type'] == 'unassignment' && is_numeric($item['description'])) {
        $res1 = lcm_query("SELECT * FROM lcm_author WHERE id_author = " . $item['description']);
        $author1 = lcm_fetch_array($res1);
        $short_description = _T('case_info_author_unassigned', array('name' => get_person_name($author1)));
    } elseif ($item['type'] == 'stage_change' || is_status_change($item['type'])) {
        $tmp = lcm_unserialize($item['description']);
        // for backward compatibility, make it optional
        if ($item['case_stage']) {
            $short_description = _Tkw('stage', $item['case_stage']);
        }
        if ($tmp['description']) {
            $short_description .= " / " . $tmp['description'];
        }
        if ($tmp['result'] || $tmp['conclusion']) {
            $short_description .= "\n" . _Ti('fu_input_conclusion');
        }
        if ($tmp['result']) {
            $short_description .= _Tkw('_crimresults', $tmp['result']) . "/";
        }
        if ($tmp['conclusion']) {
            $short_description .= _Tkw('conclusion', $tmp['conclusion']);
        }
        if ($tmp['sentence']) {
            $short_description .= "\n" . _Ti('fu_input_sentence') . _Tkw('sentence', $tmp['sentence'], array('currency' => read_meta('currency')));
        }
        if ($tmp['sentence_val']) {
            $short_description .= ": " . $tmp['sentence_val'];
        }
    } else {
        if ($item['description']) {
            if (!$make_short || strlen(lcm_utf8_decode($item['description'])) < $title_length) {
                $short_description = $item['description'];
            } else {
                $short_description = substr($item['description'], 0, $title_length) . '...';
            }
            $short_description = clean_output($short_description);
        } else {
            $short_description = _T('fu_info_emptydesc');
        }
    }
    $short_description = nl2br($short_description);
    if (empty($short_description)) {
        $short_description = _T('info_not_available');
    }
    return $short_description;
}
Example #8
0
 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";
 }
Example #9
0
$app = intval(_request('app'));
$ac = get_ac_app($app);
if (!$ac['r']) {
    die("access denied");
}
// Get the authors participating in the appointment
$q = "SELECT p.*, a.name_first, a.name_middle, a.name_last, c.title AS case_title\n\tFROM lcm_app as p\n\tLEFT JOIN lcm_case as c ON (c.id_case = p.id_case)\n\tLEFT JOIN lcm_author as a ON (a.id_author = p.id_author)\n\tWHERE p.id_app = {$app}";
$result = lcm_query($q);
if (!($row = lcm_fetch_array($result))) {
    die("There is no such appointment.");
}
lcm_page_start(_T('title_app_view') . ' ' . $row['title'], '', '', 'tools_agenda');
echo '<fieldset class="info_box">' . "\n";
echo '<p class="normal_text">' . "\n";
echo _Ti('app_input_title') . $row['title'] . "<br />\n";
echo _Ti('app_input_type') . _Tkw('appointments', $row['type']) . "<br />\n";
if ($row['hidden'] == 'Y') {
    echo '<p class="normal_text"><strong>' . _T('app_info_is_deleted') . "</strong>";
    if ($ac['a']) {
        echo " " . _T('app_info_is_deleted2');
    }
    echo "</p>\n";
}
show_page_subtitle(_T('generic_subtitle_general'), 'tools_agenda');
echo _Ti('app_input_description') . nl2br($row['description']) . "<br />\n";
echo "<br />\n";
echo _Ti('time_input_date_start') . format_date($row['start_time'], 'short');
$year_for_cal = "&annee=" . annee($row['start_time']) . "&mois=" . mois($row['start_time']) . "&jour=" . journum($row['start_time']);
// day
echo ' ' . http_href_img("calendar.php?type=jour" . $year_for_cal, 'cal-today.gif', '', _T('app_info_see_cal_for_day_tooltip'));
echo "<br />\n";
Example #10
0
    // Id followup
    // echo '<td class="tbl_cont_' . $css . '"><img src="images/lcm/dotted_angle.gif" width="15" height="15" align="left" />&nbsp;' . $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";
echo '<p><a href="edit_case.php?case=0" class="create_new_lnk">' . _T('case_button_new') . "</a></p>\n";
lcm_page_end();
Example #11
0
show_context_case_involving($fu_data['id_case']);
// Show parent appointment, if any
// [ML] todo put in inc_presentation
$q = "SELECT app.*\n\t\tFROM lcm_app_fu as af, lcm_app as app\n\t\tWHERE af.id_followup = {$followup} \n\t\t  AND af.id_app = app.id_app \n\t\t  AND af.relation = 'child'";
$res_app = lcm_query($q);
if ($app = lcm_fetch_array($res_app)) {
    echo '<li style="list-style-type: none;">' . _T('fu_input_parent_appointment') . ' ';
    echo '<a class="content_link" href="app_det.php?app=' . $app['id_app'] . '">' . _Tkw('appointments', $app['type']) . ' (' . $app['title'] . ') from ' . format_date($app['start_time']) . "</a></li>\n";
    // TRAD
}
// Show child appointment, if any
$q = "SELECT app.* \n\t\tFROM lcm_app_fu as af, lcm_app as app\n\t\tWHERE af.id_followup = {$followup} \n\t\t  AND af.id_app = app.id_app \n\t\t  AND af.relation = 'parent'";
$res_app = lcm_query($q);
if ($app = lcm_fetch_array($res_app)) {
    echo '<li style="list-style-type: none;">' . _T('fu_input_child_appointment') . ' ';
    echo '<a class="content_link" href="app_det.php?app=' . $app['id_app'] . '">' . _Tkw('appointments', $app['type']) . ' (' . $app['title'] . ') from ' . format_date($app['start_time']) . "</a></li>\n";
    // TRAD
}
// Show stage information
if ($fu_data['case_stage']) {
    // if editing an existing followup..
    if ($fu_data['case_stage']) {
        $stage_info = get_kw_from_name('stage', $fu_data['case_stage']);
    }
    $id_stage = $stage_info['id_keyword'];
    show_context_stage($fu_data['id_case'], $id_stage);
}
show_context_end();
if ($fu_data['hidden'] == 'Y') {
    echo '<p class="normal_text"><strong>' . _T('fu_info_is_deleted') . "</strong>";
    if ($admin) {
Example #12
0
 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 '&nbsp;<a href="edit_auth.php?case=' . $this->getDataInt('id_case') . '&amp;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']) . '&nbsp;' . _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";
 }
Example #13
0
function show_context_case_stage($id_case, $id_followup = 0)
{
    if (!(is_numeric($id_case) && $id_case > 0)) {
        lcm_log("Warning: show_context_case_stage, id_case not a number > 0: {$id_case}");
        return;
    }
    if (!is_numeric($id_followup)) {
        lcm_log("Warning: show_context_case_stage, id_followup not a number >= 0: {$id_followup}");
        return;
    }
    if ($id_followup) {
        $query = "SELECT case_stage as stage FROM lcm_followup WHERE id_followup = {$id_followup}";
    } else {
        $query = "SELECT stage FROM lcm_case WHERE id_case = {$id_case}";
    }
    $result = lcm_query($query);
    while ($row = lcm_fetch_array($result)) {
        // should be only once
        echo '<li style="list-style-type: none;">' . _Ti('case_input_stage') . _Tkw('stage', $row['stage']) . "</li>\n";
    }
}
Example #14
0
function show_filters_info($report)
{
    if (!$report->getOption('headers_sent')) {
        return;
    }
    $my_filters = get_filters($report->getId());
    if (count($my_filters)) {
        echo '<p class="normal_text">';
    }
    foreach ($my_filters as $f) {
        if (!$f['value']) {
            // Value may be provided by $_REQUEST
            if (isset($_REQUEST['filter_val' . $f['id_filter']])) {
                // text or number
                $f['value'] = $_REQUEST['filter_val' . $f['id_filter']];
            } elseif (isset_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'], 'year_only')) {
                // Date
                $f['value'] = get_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'], 'year_only');
            } elseif (isset_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . "_start", 'year_only') && isset_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . "_end", 'year_only')) {
                // Date interval
                $f['value'] = get_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . "_start", 'start');
                $f['value'] .= ";";
                $f['value'] .= get_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . "_end", 'end');
            } else {
                // Should never happen
                $f['value'] = _T('info_not_available');
            }
        }
        // TODO: If field.type == text and field.value is based on keyword or
        // list, use translation if known.
        if ($f['enum_type']) {
            $enum = explode(":", $f['enum_type']);
            if ($enum[0] == 'keyword') {
                if ($enum[2]) {
                    $f['value'] = _Tkw($enum[2], $f['value']);
                }
            } elseif ($enum[0] == 'list') {
                if ($enum[2]) {
                    $f['value'] = _T($enum[2] . $f['value']);
                }
            }
        }
        // Example: "Follow-up - Start: in 1 Apr 05, 00h00 - 31 Dec 05, 23h59"
        // or.....: Table - Field: type_filter value
        echo _T('rep_info_table_' . $f['table_name']) . " - " . _Ti($f['description']) . _T('rep_filter_' . $f['type']) . " ";
        switch ($f['type']) {
            case 'date_in':
                $values = split(";", $f['value']);
                echo format_date($values[0], 'short') . " - " . format_date($values[1], 'short');
                break;
            case 'date_eq':
            case 'date_ge':
            case 'date_gt':
            case 'date_le':
            case 'date_lt':
                echo format_date($f['value'], 'short');
                break;
            default:
                echo $f['value'];
        }
        echo "<br />\n";
    }
    if (count($my_filters)) {
        echo "</p>\n";
    }
}