Example #1
0
// Check for correct start position of the list
$list_pos = intval(_request('list_pos', 0));
if ($list_pos >= $number_of_rows) {
    $list_pos = 0;
}
// Position to the page info start
if ($list_pos > 0) {
    if (!lcm_data_seek($result, $list_pos)) {
        die("Error seeking position {$list_pos} in the result");
    }
}
show_find_box('client', $find_client_string, '__self__');
echo '<form action="add_client.php" method="post">' . "\n";
$headers[0]['title'] = "";
$headers[0]['order'] = 'no_order';
$headers[1]['title'] = _Th('person_input_name');
$headers[1]['order'] = 'order_name';
$headers[1]['default'] = 'ASC';
show_list_start($headers);
// Process the output of the query
for ($i = 0; $i < $prefs['page_rows'] && ($row = lcm_fetch_array($result)); $i++) {
    echo "<tr>";
    // Show checkbox
    echo "<td width='1%' class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>";
    echo "<input type='checkbox' name='clients[]' value='" . $row['id_client'] . "'>";
    echo "</td>\n";
    // Show client name
    echo "<td class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>";
    echo '<a href="client_det.php?client=' . $row['id_client'] . '" class="content_link">';
    echo highlight_matches(clean_output($row['name_first'] . ' ' . $row['name_middle'] . ' ' . $row['name_last']), $find_client_string);
    echo "</a>";
Example #2
0
 function start()
 {
     $cpt = 0;
     $headers = array();
     $headers[$cpt]['title'] = '#';
     // TRAD
     $headers[$cpt]['order'] = 'no_order';
     $cpt++;
     $headers[$cpt]['title'] = 'User';
     // TRAD
     $headers[$cpt]['order'] = 'no_order';
     $cpt++;
     $headers[$cpt]['title'] = 'Case';
     // TRAD
     $headers[$cpt]['order'] = 'no_order';
     $cpt++;
     $headers[$cpt]['title'] = _Th('time_input_date_creation');
     $headers[$cpt]['order'] = 'date_order';
     $headers[$cpt]['default'] = 'DESC';
     $cpt++;
     $headers[$cpt]['title'] = _Th('expense_input_type');
     $headers[$cpt]['order'] = 'type_order';
     $cpt++;
     $headers[$cpt]['title'] = _Th('expense_input_description');
     $headers[$cpt]['order'] = 'no_order';
     $headers[$cpt]['more'] = 'desc';
     $cpt++;
     $headers[$cpt]['title'] = "comments";
     // TRAD
     $headers[$cpt]['order'] = 'no_order';
     $cpt++;
     $headers[$cpt]['title'] = _Th('time_input_date_updated');
     $headers[$cpt]['order'] = 'upddate_order';
     $cpt++;
     // It doesn't order in a very logical way, but better
     // than nothing!
     $headers[$cpt]['title'] = _Th('expense_input_status');
     $headers[$cpt]['order'] = 'status_order';
     $cpt++;
     show_list_start($headers);
 }
Example #3
0
$custom_reports = array();
$handle = opendir("inc/config/custom/reports");
while (($f = readdir($handle)) != '') {
    if (is_file("inc/config/custom/reports/" . $f)) {
        // matches: custom/reports/alpha-num_name.php
        if (preg_match("/^([_a-zA-Z0-9]+)\\.php/", $f, $regs)) {
            $custom_reports[] = $regs[1];
        }
    }
}
if (count($custom_reports)) {
    show_page_subtitle("Custom reports", 'reports_custom');
    // TRAD
    echo '<p class="normal_text">';
    $headers = array();
    $headers[0]['title'] = _Th('rep_input_title');
    // $headers[0]['order'] = 'order_ctitle';
    // $headers[0]['default'] = 'ASC';
    show_list_start($headers);
    for ($i = 0; $i < $prefs['page_rows'] && $custom_reports[$i]; $i++) {
        echo "<tr><td class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>";
        // TODO: how to extract name of report?
        // an 'include(report) + $report->get_name() would be overkill..
        echo '<a class="content_link" href="edit_rep.php?filecustom=' . $custom_reports[$i] . '">' . $custom_reports[$i] . '</a>';
        echo "</td>\n";
        echo "</tr>\n";
    }
    show_list_end($list_pos2, $number_of_rows2, 'custom');
    echo "</p>\n";
}
lcm_page_end();
Example #4
0
     echo '</div>';
     echo '<div style="clear: right;"></div>';
     echo '<div id="autocomplete-org-data"></div>' . "\n";
     echo "</div>\n";
     echo '<div id="autocomplete-org-alt">';
     $org = new LcmOrgInfoUI();
     $org->printEdit();
     echo '</div>';
     echo "<script type=\"text/javascript\">\n\t\t\t\tautocomplete('orgsearchkey', 'autocomplete-org-popup', 'ajax.php', 'autocomplete-org-data', 'autocomplete-org-alt')\n\t\t\t\t</script>\n";
     echo "</div>\n";
     // closes box that hides this form by default
 }
 //
 // For to find or create new client for case
 //
 show_page_subtitle(_Th('title_client_view'), 'clients_intro');
 echo '<p class="normal_text">';
 echo '<input type="checkbox"' . isChecked(_session('add_client')) . 'name="add_client" id="box_new_client" onclick="display_block(\'new_client\', \'flip\')" />';
 echo '<label for="box_new_client">' . _T('case_button_add_client') . '</label>';
 echo "</p>\n";
 // Open box that hides this form by default
 echo '<div id="new_client" ' . (_session('add_client') ? '' : ' style="display: none;"') . '>';
 echo "<div style='overflow: hidden; width: 100%;'>";
 echo '<div style="float: left; text-align: right; width: 29%;">';
 echo '<p class="normal_text" style="margin: 0; padding: 4px;">' . _Ti('input_search_client') . '</p>';
 echo "</div>\n";
 echo '<div style="float: right; width: 69%;">';
 echo '<p class="normal_text" style="margin: 0; padding: 4px;"><input type="text" name="clientsearchkey" id="clientsearchkey" size="25" />' . "</p>\n";
 echo '<span id="autocomplete-client-popup" class="autocomplete" style="visibility: hidden;"><span></span></span>';
 echo '</div>';
 echo '<div style="clear: right;"></div>';
Example #5
0
lcm_bubble('case_ac');
show_context_start();
show_context_case_title($case);
show_context_case_involving($case);
show_context_end();
?>

<form action="upd_auth.php" method="post">
	<table border="0" class="tbl_usr_dtl" width="99%">
	<tr>
		<th align="center" class="heading"><?php 
echo _Th('case_input_author');
?>
</th>
		<th align="center" class="heading"><?php 
echo _Th('case_ac_input_rights');
?>
</th>
	</tr>

<?php 
while ($row = lcm_fetch_array($result)) {
    echo "<tr>\n";
    // User name
    echo '<td align="left">';
    echo '<a href="author_det.php?author=' . $row['id_author'] . '" class="content_link"' . ' title="' . _T('case_tooltip_view_author_details', array('author' => get_person_name($row))) . '">' . get_person_name($row) . '</a>';
    echo "</td>\n";
    // Access rights in case
    echo '<td align="center">';
    echo '<select name="auth[' . $row['id_author'] . ']">' . "\n";
    $all_rights = array('read', 'write', 'admin', '', 'remove');
Example #6
0
function show_attachments_list($type, $id_type, $id_author = 0)
{
    if (!($type == 'case' || $type == 'client' || $type == 'org')) {
        lcm_panic("unknown type -" . $type . "-");
    }
    $q = "SELECT * \n\t\t\tFROM lcm_" . $type . "_attachment \n\t\t\tWHERE content IS NOT NULL ";
    if ($id_type) {
        $q .= " AND id_" . $type . " = " . intval($id_type);
    }
    if ($id_author) {
        $q .= " AND id_author = " . intval($id_author);
    }
    $result = lcm_query($q);
    $i = lcm_num_rows($result);
    if ($i > 0) {
        echo '<table border="0" align="center" class="tbl_usr_dtl" width="99%">' . "\n";
        echo "<tr>\n";
        if ($id_author) {
            echo '<th class="heading" width="1%">' . _Th($type . '_input_id') . "</th>\n";
        }
        echo '<th class="heading">' . _Th('file_input_type') . "</th>\n";
        echo '<th class="heading">' . _Th('file_input_description') . "</th>\n";
        echo '<th class="heading">' . _Th('file_input_size') . "</th>\n";
        echo '<th class="heading">' . "</th>\n";
        echo "</tr>\n";
        for ($i = 0; $row = lcm_fetch_array($result); $i++) {
            echo "<tr>\n";
            if ($id_author) {
                echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '" align="left">';
                echo '<a href="' . $type . '_det.php?' . $type . '=' . $row['id_' . $type] . '" class="content_link">' . $row['id_' . $type] . '</a>';
                echo "</td>\n";
            }
            // Mimetype
            // [ML] We were using the mimetype sent by the browser, but it
            // ends up being rather useless, since MSIE and Firefox don't agree on
            // the mimetypes.. ex: .jpg = image/jpeg (FFx), but under MSIE is image/pjeg
            // So may as well just use the extention of the file, even if not reliable.
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '" align="left">';
            echo '<a title="' . $row['type'] . '" ' . 'href="view_file.php?type=' . $type . '&amp;file_id=' . $row['id_attachment'] . '">';
            if (preg_match("/\\.([a-zA-Z0-9]+)\$/", $row['filename'], $regs) && is_file("images/mimetypes/" . strtolower($regs[1]) . ".png")) {
                echo '<img src="images/mimetypes/' . $regs[1] . '.png" border="0" alt="' . $row['type'] . '" />';
            } else {
                echo '<img src="images/mimetypes/unknown.png" border="0" alt="' . $row['type'] . '" />';
            }
            echo '</a>';
            echo '</td>';
            // File name (or description, if any)
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . '<a title="' . $row['filename'] . '" ' . 'href="view_file.php?type=' . $type . '&amp;file_id=' . $row['id_attachment'] . '" class="content_link">';
            echo trim($row['description']) ? $row['description'] : $row['filename'];
            echo '</a></td>';
            // Size
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . size_in_bytes($row['size']) . '</td>';
            // Delete icon
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">';
            if ($GLOBALS['author_session']['status'] == 'admin' || $row['id_author'] == $GLOBALS['author_session']['id_author'] && ($type == 'case' ? allowed($id_type, 'e') : true)) {
                echo '<label for="id_rem_file' . $row['id_attachment'] . '">';
                echo '<img src="images/jimmac/stock_trash-16.png" width="16" height="16" ' . 'alt="' . _T('file_info_delete') . '" title="' . _T('file_info_delete') . '" />';
                echo '</label>&nbsp;';
                echo '<input type="checkbox" onclick="lcm_show(\'btn_delete\')" ' . 'id="id_rem_file' . $row['id_attachment'] . '" name="rem_file[]" ' . 'value="' . $row['id_attachment'] . '" />';
            }
            echo '</td>';
            echo "</tr>\n";
        }
        echo "</table>\n";
        echo '<p align="right" style="visibility: hidden">';
        echo '<input type="submit" name="submit" id="btn_delete" value="' . _T('button_validate') . '" class="search_form_btn" />';
        echo "</p>\n";
    } else {
        echo '<p class="normal_text">' . _T('file_info_emptylist') . "</p>\n";
    }
}
Example #7
0
 $result = lcm_query($q);
 // Show table headers
 echo '<fieldset class="info_box">';
 show_page_subtitle(_T('case_subtitle_times'), 'reports_intro');
 $link_details = new Link();
 $link_details->addVar('more_times', intval(!$show_more_times));
 echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
 echo "<tr>\n";
 echo "<th class='heading'>" . _Th('case_input_author') . '&nbsp;' . '<a title="' . _T('fu_button_stats_' . ($show_more_times ? 'less' : 'more')) . '" href="' . $link_details->getUrl() . '">' . '<img src="images/spip/' . ($show_more_times ? 'moins' : 'plus') . '.gif" alt="" border="0" />' . '</a>' . "</th>\n";
 echo "<th class='heading' width='120' nowrap='nowrap' align='right'>" . _Th('time_input_length') . ' (' . _T('time_info_short_hour') . ")</th>\n";
 $total_time = 0;
 $total_sum_billed = 0.0;
 $meta_sum_billed = read_meta('fu_sum_billed');
 if ($meta_sum_billed == 'yes') {
     $currency = read_meta('currency');
     echo "<th class='heading' width='120' nowrap='nowrap' align='right'>" . _Th('fu_input_sum_billed') . ' (' . $currency . ")</th>\n";
 }
 echo "</tr>\n";
 // Show table contents & calculate total
 while ($row = lcm_fetch_array($result)) {
     $total_time += $row['time'];
     $total_sum_billed += $row['sumbilled'];
     echo "<tr><td>";
     echo get_person_name($row);
     echo '</td><td align="right" valign="top">';
     echo format_time_interval_prefs($row['time']);
     echo "</td>\n";
     if ($meta_sum_billed == 'yes') {
         echo '<td align="right" valign="top">';
         echo format_money($row['sumbilled']);
         echo "</td>\n";
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
    // TODO: add $_SESSION['errors']['generic'] message?
    header('Location: ' . $dest_link->getUrlForHeader());
    exit;
}
show_context_start();
show_context_case_title($case);
show_context_case_involving($case);
show_context_end();
show_find_box('author', $find_author_string, '__self__');
echo '<form action="add_auth.php" method="post">' . "\n";
$headers = array();
$headers[0]['title'] = '';
$headers[0]['order'] = 'no_order';
$headers[1]['title'] = _Th('person_input_name');
$headers[1]['order'] = 'order_name';
$headers[2]['title'] = _Th('authoredit_input_status');
$headers[2]['order'] = 'order_status';
show_list_start($headers);
for ($i = 0; $i < $prefs['page_rows'] && ($row = lcm_fetch_array($result)); $i++) {
    echo "<tr>\n";
    echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">';
    echo '<input type="checkbox" name="authors[]" value="' . $row['id_author'] . '" />';
    echo "</td>\n";
    echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . get_person_name($row) . "</td>\n";
    echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . _T('authoredit_input_status_' . $row['status']) . "</td>\n";
    echo "</tr>\n";
}
show_list_end($list_pos, $number_of_rows);
?>

<input type="hidden" name="case" value="<?php 
Example #10
0
// List of recent follow-ups
//
echo '<a name="fu"></a>' . "\n";
//echo "<div class='prefs_column_menu_head'>" . 'Recent follow-ups' . "</div>\n";
// $headers[0]['title'] = "#";
//$headers[0]['order'] = 'no_order';
$headers[0]['title'] = _Th('time_input_date_start');
$headers[0]['order'] = 'fu_order';
$headers[0]['default'] = 'DESC';
$headers[1]['title'] = $prefs['time_intervals'] == 'absolute' ? _Th('time_input_date_end') : _Th('time_input_length');
//$headers[1]['order'] = 'no_order';
$headers[2]['title'] = _Th('case_input_author');
//$headers[2]['order'] = 'no_order';
$headers[3]['title'] = _Th('fu_input_type');
//$headers[3]['order'] = 'no_order';
$headers[4]['title'] = _Th('fu_input_description');
//$headers[4]['order'] = 'no_order';
echo '<p class="normal_text">' . "\n";
show_list_start($headers);
// Get recent followups from SQL
// Prepare query
$q = "SELECT\tc.id_case, c.title, c.status, c.date_creation,\n\t\tfu.*,\n\t\ta.name_first, a.name_middle, a.name_last\n\tFROM lcm_case as c, lcm_followup as fu, lcm_author as a, lcm_case_author as ca\n\tWHERE c.id_case=fu.id_case\n\t  AND fu.id_author=a.id_author\n\t  AND ca.id_case=fu.id_case\n\t  AND ca.id_author=fu.id_author";
// Add filtering by user access rights
if ($author_session['status'] != 'admin' || $case_owner != 'all') {
    // Select cases on which the user is assigned
    $q .= "\tAND ( (ca.id_author=" . $author_session['id_author'] . ")";
    // Or cases which are public
    if ($case_owner == 'public') {
        $q .= "\tOR (c.public=1)";
    }
    $q .= ")";
Example #11
0
 function printHeaderValue($val)
 {
     $val = _Th(remove_number_prefix($val));
     echo '"' . $val . '", ';
 }
Example #12
0
 echo '<fieldset class="info_box">';
 echo '<div class="prefs_column_menu_head">' . _T('client_subtitle_associated_org') . "</div>\n";
 echo '<form action="add_org_cli.php" method="post">' . "\n";
 echo '<input type="hidden" name="client" value="' . $client . '" />' . "\n";
 //
 // Show organisation(s)
 //
 $q = "SELECT lcm_org.id_org,name\n\t\t\t\t\t\tFROM lcm_client_org,lcm_org\n\t\t\t\t\t\tWHERE id_client={$client}\n\t\t\t\t\t\t\tAND lcm_client_org.id_org=lcm_org.id_org";
 $result = lcm_query($q);
 $show_table = false;
 if (lcm_num_rows($result)) {
     $show_table = true;
     echo '<table border="0" class="tbl_usr_dtl" width="100%">' . "\n";
     echo "<tr>\n";
     echo '<th class="heading">&nbsp;</th>';
     echo '<th class="heading">' . _Th('org_input_name') . '</th>';
     echo '<th class="heading">&nbsp;</th>';
     echo "</tr>\n";
 } else {
     // TODO info message?
 }
 $i = 0;
 while ($row1 = lcm_fetch_array($result)) {
     echo "<tr>\n";
     // Image
     echo '<td width="25" align="center" class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '"><img src="images/jimmac/stock_people.png" alt="" height="16" width="16" /></td>' . "\n";
     // Name of org
     echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '"><a style="display: block;" href="org_det.php?org=' . $row1['id_org'] . '" class="content_link">' . $row1['name'] . "</a></td>\n";
     // Delete association
     echo '<td width="1%" nowrap="nowrap" class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">';
     echo '<label for="id_rem_org_' . $row1['id_org'] . '">';
Example #13
0
 //
 case 'representatives':
     echo '<fieldset class="info_box">';
     echo '<div class="prefs_column_menu_head">' . _T('org_subtitle_representatives') . "</div><br />\n";
     echo '<form action="add_cli_org.php" method="post">' . "\n";
     echo '<input type="hidden" name="org" value="' . $org . '" />' . "\n";
     // Show organisation representative(s)
     $q = "SELECT cl.id_client, name_first, name_middle, name_last\n\t\t\t\t\tFROM lcm_client_org as clo, lcm_client as cl\n\t\t\t\t\tWHERE id_org = {$org} \n\t\t\t\t\t\tAND clo.id_client = cl.id_client";
     $result = lcm_query($q);
     $show_table = false;
     if (lcm_num_rows($result)) {
         $show_table = true;
         echo '<table class="tbl_usr_dtl" width="100%">' . "\n";
         echo "<tr>\n";
         echo '<th class="heading">' . "#" . '</th>';
         echo '<th class="heading" width="99%">' . _Th('person_input_name') . '</th>';
         echo '<th class="heading">&nbsp;</th>';
         echo "</tr>\n";
     } else {
         // TODO info message?
     }
     $i = 0;
     while ($row = lcm_fetch_array($result)) {
         echo "<tr>\n";
         // ID
         echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . $row['id_client'] . '</td>';
         // Name of client
         echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '"><a href="client_det.php?client=' . $row['id_client'] . '" class="content_link">';
         echo get_person_name($row) . "</a></td>";
         // Delete association
         echo '<td nowrap="nowrap" class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">';
Example #14
0
function show_report_field_edit($type, $rep_info)
{
    $src_type = $rep_info[$type . '_src_type'];
    $src_name = $rep_info[$type . '_src_name'];
    if ($src_type == 'table' && $src_name && !preg_match('/^lcm_/', $src_name)) {
        $src_name = 'lcm_' . $src_name;
    }
    // Extract source type, if any
    if ($src_type && $src_name) {
        if ($src_type == 'keyword') {
            $kwg = get_kwg_from_name($src_name);
            echo '<p class="normal_text">' . _Ti('rep_info_source_' . $src_type) . " (" . _T('rep_info_table_lcm_' . $kwg['type']) . ") " . _T(remove_number_prefix($kwg['title']));
        } else {
            echo "<p class='normal_text'>" . _Ti('rep_info_source_' . $src_type) . _T('rep_info_table_' . $src_name);
        }
        // Show list of fields for line/col, if any
        $my_id = $type == 'col' ? 'id_column' : 'id_line';
        $my_fields = array();
        $query = "SELECT " . $my_id . ", f.id_field, f.description \n\t\t\tFROM lcm_rep_" . $type . " as rl, lcm_fields as f\n\t\t\tWHERE id_report = " . $rep_info['id_report'] . "\n\t\t\tAND rl.id_field = f.id_field\n\t\t\tORDER BY col_order, " . $my_id . " ASC";
        $result_fields = lcm_query($query);
        if (lcm_num_rows($result_fields)) {
            echo "</p>\n";
            echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
            while ($field = lcm_fetch_array($result_fields)) {
                echo "<tr>\n";
                echo "<td>" . _Th($field['description']) . "</td>\n";
                echo "<td><a href='upd_rep_field.php?rep=" . $rep_info['id_report'] . "&amp;" . "remove=" . $type . "&amp;" . $my_id . "=" . $field[$my_id] . "' class='content_link'>" . "X" . "</a></td>\n";
                // ACCESSIBILITY
                echo "</tr>\n";
                array_push($my_fields, $field['id_field']);
            }
            echo "</table>\n";
        } else {
            if (!$rep_info['filecustom']) {
                // Allow to change the source table
                echo ' <a href="upd_rep_field.php?rep=' . $rep_info['id_report'] . '&amp;unselect_' . $type . '=1" class="content_link">' . "X" . '</a>';
                // TRAD ACCESSIBILITY
                echo "</p>\n";
            }
        }
        // Add field (if line_src_type == table)
        // TODO: add 'not in (...existing fields..)
        $query = "SELECT *\n\t\t\tFROM lcm_fields\n\t\t\tWHERE table_name = '" . $src_name . "'";
        $result = lcm_query($query);
        if (lcm_num_rows($result)) {
            echo "\n<br />\n\n";
            echo "<form action='upd_rep_field.php' name='frm_" . $type . "_additem' method='get'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo "<input name='add' value='" . $type . "' type='hidden' />\n";
            echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
            echo "<tr>\n";
            echo "<th class='heading'>" . _Ti('rep_input_item_add') . "</th>\n";
            echo "<td>\n";
            echo "<select name='id_field' class='sel_frm'>";
            echo "<option value=''>...</option>\n";
            while ($row = lcm_fetch_array($result)) {
                echo "<option value='" . $row['id_field'] . "'>" . _Th($row['description']) . "</option>\n";
            }
            echo "</select>\n";
            echo "<button class='simple_form_btn' name='validate_" . $type . "_additem'>" . _T('button_validate') . "</button>\n";
            echo "</td>\n";
            echo "</tr>\n";
            echo "</table>\n";
            echo "</form>\n";
        }
    } else {
        if (!$src_type || $src_type != 'keyword') {
            echo "<form action='upd_rep_field.php' name='frm_" . $type . "_source' method='post'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo '<p class="normal_text">' . f_err_star('rep_' . $type) . _Ti('rep_info_source_table');
            echo "<input name='select_" . $type . "_type' value='table' type='hidden' />\n";
            echo "<select name='select_" . $type . "_name' class='sel_frm'>\n\t\t\t\t<option value='author'>" . _T('rep_info_table_lcm_author') . "</option>\n\t\t\t\t<option value='case'>" . _T('rep_info_table_lcm_case') . "</option>\n\t\t\t\t<option value='stage'>" . _T('rep_info_table_lcm_stage') . "</option>\n\t\t\t\t<option value='client'>" . _T('rep_info_table_lcm_client') . "</option>\n\t\t\t\t<option value='followup'>" . _T('rep_info_table_lcm_followup') . "</option>\n\t\t\t\t</select>\n";
            echo "<button class='simple_form_btn' name='validate_" . $type . "_source'>" . _T('button_validate') . "</button>\n";
            echo "</p>\n";
            echo "</form>\n";
        }
        if (!$src_type) {
            echo '<p class="normal_text">' . _T('info_or') . "</p>\n";
        }
        if (!$src_type || $src_type != 'table') {
            echo "<form action='upd_rep_field.php' name='frm_" . $type . "_source' method='post'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo "<p class='normal_text'>" . _Ti('rep_info_source_keyword');
            echo "<input name='select_" . $type . "_type' value='keyword' type='hidden' />\n";
            // Restrict list of keywords if custom report
            if ($rep_info['filecustom']) {
                include_custom_report($rep_info['filecustom']);
                $obj = new CustomReportSpecs();
                $info = $type == 'line' ? $obj->getReportLine() : $obj->getReportCol();
                if (substr($info['name'], 0, 4) == 'FOR:') {
                    $choices = split(':', $info['name']);
                    $all_kwgs = get_kwg_all($choices[1], true);
                } else {
                    lcm_panic("Error in custom report specifications.");
                }
            } else {
                $all_kwgs = get_kwg_all('', true);
            }
            echo "<select name='select_" . $type . "_name' class='sel_frm'>\n";
            echo "<option value=''>...</option>\n";
            foreach ($all_kwgs as $kwg) {
                echo "<option value='" . $kwg['name'] . "'>" . _T('rep_info_table_lcm_' . $kwg['type']) . " - " . _T(remove_number_prefix($kwg['title'])) . "</option>\n";
            }
            echo "</select>\n";
            echo "<button class='simple_form_btn' name='validate_" . $type . "_source_kw'>" . _T('button_validate') . "</button>\n";
            echo "</p>\n";
            echo "</form>\n";
        }
    }
}
Example #15
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 #16
0
 function setupReportLines()
 {
     $this->addComment("setupReportLines() called.");
     $q = "SELECT *\n\t\t\t\tFROM lcm_rep_line as l, lcm_fields as f\n\t\t\t\tWHERE id_report = " . $this->getId() . "\n\t\t\t\tAND l.id_field = f.id_field\n\t\t\t\tORDER BY col_order, id_line ASC";
     $result = lcm_query($q);
     while ($row = lcm_fetch_array($result)) {
         $my_line_table = $row['table_name'];
         $this->addLine(prefix_field($row['table_name'], $row['field_name']));
         $this->addHeader(_Th($row['description']), $row['filter'], $row['enum_type'], '', $row['field_name']);
         if ($row['field_name'] == 'count(*)') {
             $this->setOption('do_grouping', 'yes');
         }
         // $do_grouping = true;
     }
     if (count($this->getLines())) {
         return;
     }
     //
     // No fields were specified: show them all (avoids errors)
     //
     if ($this->rep_info['line_src_type'] == 'table') {
         $q = "SELECT * \n\t\t\t\t\tFROM lcm_fields \n\t\t\t\t\tWHERE table_name = 'lcm_" . $this->rep_info['line_src_name'] . "'\n\t\t\t\t\t  AND field_name != 'count(*)'";
         $result = lcm_query($q);
         while ($row = lcm_fetch_array($result)) {
             $this->addLine(prefix_field($row['table_name'], $row['field_name']));
             $this->addHeader(_Th($row['description']), $row['filter'], $row['enum_type'], '', $row['field_name']);
         }
     } elseif ($this->rep_info['line_src_type'] == 'keyword') {
         $kwg = get_kwg_from_name($this->rep_info['line_src_name']);
         $this->addLine("k.title as 'TRAD'");
         $this->addHeader(_Th(remove_number_prefix($kwg['title'])), $kwg['filter'], $kwg['enum_type'], '', 'k.id_keyword');
         // XXX not sure about id_keyword
     }
 }
Example #17
0
// Check for correct start position of the list
$list_pos = intval(_request('list_pos', 0));
if ($list_pos >= $number_of_rows) {
    $list_pos = 0;
}
// Position to the page info start
if ($list_pos > 0) {
    if (!lcm_data_seek($result, $list_pos)) {
        die("Error seeking position {$list_pos} in the result");
    }
}
show_find_box('org', $find_org_string, '__self__');
echo '<form action="add_client.php" method="post">' . "\n";
$headers[0]['title'] = "";
$headers[0]['order'] = 'no_order';
$headers[1]['title'] = _Th('org_input_name');
$headers[1]['order'] = 'order_name';
$headers[1]['default'] = 'ASC';
show_list_start($headers);
for ($i = 0; $i < $prefs['page_rows'] && ($row = lcm_fetch_array($result)); $i++) {
    echo "<tr>\n";
    // Show checkbox
    echo "<td width='1%' class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>";
    echo "<input type='checkbox' name='orgs[]' value='" . $row['id_org'] . "'>";
    echo "</td>\n";
    // Show org name
    echo "<td class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>";
    echo '<a href="org_det.php?org=' . $row['id_org'] . '" class="content_link">';
    echo highlight_matches(clean_output($row['name']), $find_org_string);
    echo "</a>";
    echo "</td>\n";
Example #18
0
    }
    $report->printEndLine();
    $report->incrementLine();
}
//
// Footer
//
$css = 'class="tbl_cont_' . (($cpt_lines + 1) % 2 ? "light" : "dark") . '"';
$cpt_tmp = 0;
$report->printStartLine();
$my_headers = $report->getHeaders();
foreach ($my_headers as $h) {
    if (!preg_match('/^(.+\\.)?id_.+/', $h['field_name']) && ($h['filter'] == 'number' || $h['filter'] == 'currency' || $h['filter_special'] == 'time_length')) {
        $report->printValue($report->getTotal($cpt_tmp), $h, $css);
    } elseif ($cpt_tmp == 0) {
        $report->printValue(_Th('generic_input_total'), $h, $css);
    } else {
        $report->printValue('', $h, $css);
    }
    $cpt_tmp++;
}
$report->printEndLine();
$report->printEndDoc();
if ($report->getOption('headers_sent') == 'yes') {
    echo "</table>\n";
    echo "<p>Number of rows: " . $report->getRowCount() . "</p>\n";
    // TRAD
    // Report footnotes (ex: signed by manager, etc. -- allow HTML)
    echo $rep_info['notes'];
    if ($report->getOption('allow_show_nokw') == 'yes') {
        $tmp_link = new Link();