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"; } }
// echo '<form action="listexps.php" method="get">' . "\n"; echo "<p class=\"normal_text\">\n"; echo _T('input_filter_case_owner'); echo '<select name="case_owner">'; foreach ($types_owner as $t => $foo) { $sel = isSelected($prefs['case_owner'] == $t); echo '<option value="' . $t . '"' . $sel . '>' . _T('expense_filter_owner_option_' . $t) . "</option>\n"; } echo "</select>\n"; echo '<select name="case_period">'; foreach ($types_period as $key => $val) { $sel = isSelected($prefs['case_period'] == $val); echo '<option value="' . $val . '"' . $sel . '>' . _T('case_filter_period_option_' . $key) . "</option>\n"; } $q_dates = "SELECT DISTINCT " . lcm_query_trunc_field('date_creation', 'year') . " as year\n\t\t\tFROM lcm_expense as e\n\t\t\tWHERE " . $q_owner; $result = lcm_query($q_dates); while ($row = lcm_fetch_array($result)) { $sel = isSelected($prefs['case_period'] == $row['year']); echo '<option value="' . $row['year'] . '"' . $sel . '>' . _T('case_filter_period_option_year', array('year' => $row['year'])) . "</option>\n"; } echo "</select>\n"; echo ' <button name="submit" type="submit" value="submit" class="simple_form_btn">' . _T('button_validate') . "</button>\n"; echo "</p>\n"; echo "</form>\n"; // Process the output of the query $exp_list = new LcmExpenseListUI(); $exp_list->setSearchTerm($find_exp_string); $exp_list->start(); $exp_list->printList(); $exp_list->finish();
// if user and no cases + no follow-ups... if (count($list_cases)) { $q .= " fu.id_case IN (" . implode(",", $list_cases) . "))"; } else { $q .= " fu.id_case IN ( 0 ))"; } } // Period (date_creation) to show if ($prefs['case_period'] < 1900) { // since X days // $q .= " AND TO_DAYS(NOW()) - TO_DAYS(date_start) < " . $prefs['case_period']; $q .= " AND " . lcm_query_subst_time('date_start', 'NOW()') . ' < ' . $prefs['case_period'] * 3600 * 24; } else { // for year X // $q .= " AND YEAR(date_start) = " . $prefs['case_period']; $q .= " AND " . lcm_query_trunc_field('date_start', 'year') . ' = ' . $prefs['case_period']; } // Add ordering $fu_order = "DESC"; if (isset($_REQUEST['fu_order'])) { if ($_REQUEST['fu_order'] == 'ASC' || $_REQUEST['fu_order'] == 'DESC') { $fu_order = $_REQUEST['fu_order']; } } $q .= " ORDER BY date_start {$fu_order}, id_followup {$fu_order}"; $result = lcm_query($q); // Check for correct start position of the list $number_of_rows = lcm_num_rows($result); $fu_list_pos = 0; if (isset($_REQUEST['fu_list_pos'])) { $fu_list_pos = $_REQUEST['fu_list_pos'];
function printList() { global $prefs; // Select cases of which the current user is author $q = "SELECT DISTINCT c.id_case, title, status, public, pub_write, date_creation\n\t\t\tFROM lcm_case as c NATURAL JOIN lcm_case_author as a "; if ($this->search) { $q .= " NATURAL LEFT JOIN lcm_keyword_case as kc "; } // // Apply filters to SELECT output // $q .= " WHERE 1=1 "; // Add search criteria, if any if ($this->search) { $q .= " AND ("; if (is_numeric($this->search)) { $q .= " (c.id_case = {$this->search}) OR "; } $q .= " (kc.value LIKE '%" . $this->search . "%') OR " . " (c.title LIKE '%" . $this->search . "%') "; $q .= " )"; } // // Case owner: may be used by listcases.php, archives.php, author_det.php, etc. // Also, it may be a user checking another user's profile (in that case, show only public cases) // or it may be an admin checking another user's profile. etc. // global $author_session; $owner_filter = $this->getDataString('owner', $prefs['case_owner']); $owner_id = $this->getDataInt('id_author', $author_session['id_author']); $q_owner = " (a.id_author = " . $owner_id; if ($owner_id == $author_session['id_author']) { // Either in listcases, or user looking at his page in author_det if ($owner_filter == 'public') { $q_owner .= " OR c.public = 1"; } if ($author_session['status'] == 'admin' && $owner_filter == 'all') { $q_owner .= " OR 1=1 "; } } else { // If not an admin, show only public cases of that user if ($author_session['status'] != 'admin') { $q_owner .= " AND c.public = 1"; } } $q_owner .= " ) "; $q .= " AND " . $q_owner; // Period (date_creation) to show if ($this->date_start || $this->date_end) { if ($this->date_start) { $q .= " AND date_creation >= '" . $this->date_start . "'"; } if ($this->date_end) { $q .= " AND date_creation <= '" . $this->date_end . "'"; } } else { if ($prefs['case_period'] < 1900) { // since X days $q .= " AND " . lcm_query_subst_time('date_creation', 'NOW()') . ' < ' . $prefs['case_period'] * 3600 * 24; } else { // for year X $q .= " AND " . lcm_query_trunc_field('date_creation', 'year') . ' = ' . $prefs['case_period']; } } // // Sort results // $sort_clauses = array(); $sort_allow = array('ASC' => 1, 'DESC' => 1); // Sort cases by creation date if ($sort_allow[_request('status_order')]) { $sort_clauses[] = "status " . _request('status_order'); } if ($sort_allow[_request('case_order')]) { $sort_clauses[] = 'date_creation ' . _request('case_order'); } elseif ($sort_allow[_request('upddate_order')]) { $sort_clauses[] = "date_update " . _request('upddate_order'); } else { $sort_clauses[] = 'date_creation DESC'; } // default $q .= " ORDER BY " . implode(', ', $sort_clauses); $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++) { show_listcase_item($row, $i, $this->search); } }
function lcm_page_start($title = "", $css_files = "", $meta = '', $help_code = '') { global $connect_id_auteur; global $connect_status; global $auth_can_disconnect, $connect_login; global $options; global $lcm_lang, $lcm_lang_rtl, $lcm_lang_left, $lcm_lang_right; global $clean_link; global $prefs; // Clean the global link (i.e. remove actions passed in the URL) $clean_link->delVar('var_lang'); $clean_link->delVar('set_options'); $clean_link->delVar('set_couleur'); $clean_link->delVar('set_disp'); $clean_link->delVar('set_ecran'); lcm_html_start($title, $css_files, $meta); // // Title (mandatory) and description (may be empty) of the site // $site_name = _T(read_meta('site_name')); if (!$site_name) { $site_name = _T('title_software'); } $site_desc = _T(read_meta('site_description')); // // Most of the header/navigation html // echo '<div id="header"> <a href="summary.php" class="balance_link"> </a> <h1 class="lcm_main_head"><a href="summary.php" class="head_ttl_link">' . $site_name . '</a></h1> <div class="lcm_slogan"><a href="summary.php" class="head_subttl_link">' . $site_desc . "</a></div>\n\t\t<br />\n\t</div>\n"; echo "<div id='wrapper_" . $prefs['screen'] . "'>\n\t\t<div id=\"container_" . $prefs['screen'] . "\">\n\t\t\t<div id=\"content_" . $prefs['screen'] . "\">\n\t\t\t<!-- This is the navigation column, usually used for menus and brief information -->\n\t\t\t\t<div id=\"navigation_menu_column\">\n\t\t\t\t<!-- Start of navigation_menu_column content -->\n\t\t\t\t\t<div class=\"nav_menu_box\">\n\t\t\t\t\t\t<div class=\"nav_column_menu_head\"><div class=\"mm_main_menu\">" . _T('menu_main') . "</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<ul class=\"nav_menu_list\">"; echo show_navmenu_item("listcases.php", 'main_cases'); // Require to be explicitly off in order to hide the menu item (avoid config errors) if (read_meta('client_hide_all') != 'yes') { echo show_navmenu_item("listclients.php", 'main_clients'); } if (read_meta('org_hide_all') != 'yes') { echo show_navmenu_item("listorgs.php", 'main_orgs'); } if (read_meta('expenses_hide_all') != 'yes') { echo show_navmenu_item("listexps.php", "main_expenses"); } echo show_navmenu_item("listauthors.php", 'main_authors'); echo "</ul>\n"; echo "</div>\n"; if ($connect_status == 'admin') { echo "<div class=\"nav_menu_box\">\n"; echo "<div class=\"nav_column_menu_head\"><div class=\"mm_admin\">" . _T('menu_admin') . "</div></div>\n"; echo "<ul class=\"nav_menu_list\">"; show_navmenu_item("config_site.php", "admin_siteconf"); show_navmenu_item("archive.php", "admin_archives"); show_navmenu_item("listreps.php", "admin_reports"); show_navmenu_item("keywords.php", "admin_keywords"); echo "</ul>\n"; echo "</div>\n"; } // Show today's date if ($title != _T('title_upgrade_database')) { echo "<div class=\"nav_menu_box\">\n"; echo "<div class=\"nav_column_menu_head\">\n"; echo "<div class=\"mm_calendar\">" . _T('menu_calendar') . "</div>\n"; echo "</div>\n"; // Show calendar include_lcm('inc_calendar'); $now = date('Y-m-d'); echo "<table border='0' align='center'><tr><td>\n"; // Temporary? [ML] echo http_calendrier_agenda(mois($now), annee($now), jour($now), mois($now), annee($now), false, 'calendar.php'); echo "</td></tr></table>\n"; echo "</div>\n"; // Start agenda box echo '<div class="nav_menu_box">' . "\n"; echo '<div class="nav_column_menu_head">'; echo '<div class="mm_agenda">' . _T('menu_agenda') . "</div>\n"; echo "</div>\n"; $events = false; // Show appointments for today $q = "SELECT app.id_app, start_time, type, title\n\t\t\tFROM lcm_app as app, lcm_author_app as aut\n\t\t\tWHERE aut.id_author=" . $GLOBALS['author_session']['id_author'] . "\n\t\t\tAND app.id_app = aut.id_app\n\t\t\tAND " . lcm_query_trunc_field('app.start_time', 'day') . "\n\t\t\t= " . lcm_query_trunc_field('NOW()', 'day') . "\n\t\t\tORDER BY app.reminder ASC"; $result = lcm_query($q); if (lcm_num_rows($result) > 0) { $events = true; $today = getdate(time()); echo "<p class=\"nav_column_text\">\n" . '<strong><a class="content_link" href="calendar.php?type=jour' . "&jour=" . $today['mday'] . "&mois=" . $today['mon'] . "&annee=" . $today['year'] . '">' . _Th('calendar_button_now') . "</a></strong><br />\n"; echo "</p>\n"; echo "<ul class=\"small_agenda\">\n"; while ($row = lcm_fetch_array($result)) { echo "<li><a href=\"app_det.php?app=" . $row['id_app'] . "\">" . heures($row['start_time']) . ':' . minutes($row['start_time']) . " - " . $row['title'] . "</a></li>\n"; } echo "</ul>\n"; echo "<hr class=\"hair_line\" />\n"; } // Show next appointments $q = "SELECT a.id_app, a.start_time, a.type, a.title\n\t\t\tFROM lcm_app as a, lcm_author_app as aa\n\t\t\tWHERE (aa.id_author = " . $GLOBALS['author_session']['id_author'] . "\n\t\t\t\t\tAND a.id_app = aa.id_app\n\t\t\t\t\tAND a.start_time >= '" . date('Y-m-d H:i:s', (int) ceil(time() / 86400) * 86400) . "')\n\t\t\tORDER BY a.reminder ASC\n\t\t\tLIMIT 5"; $result = lcm_query($q); if (lcm_num_rows($result) > 0) { $events = true; echo "<p class=\"nav_column_text\">\n"; echo "<strong>" . _T('calendar_button_nextapps') . "</strong><br />\n"; echo "</p>\n"; echo "<ul class=\"small_agenda\">\n"; while ($row = lcm_fetch_array($result)) { echo "<li><a href=\"app_det.php?app=" . $row['id_app'] . "\">" . format_date($row['start_time'], 'short') . " - " . $row['title'] . "</a></li>\n"; } echo "</ul>\n"; } if (!$events) { echo '<p class="nav_column_text">' . _T('calendar_info_noacts') . "</p>\n"; } // my appointments echo ' <a href="author_det.php?tab=appointments&author=' . $GLOBALS['author_session']['id_author'] . '" title="' . _T('title_agenda_list') . '">' . '<img src="images/jimmac/stock_show-form-dialog.png" border="0" width="16" height="16" alt="" /></a>'; // new appointment echo ' <a href="edit_app.php?app=0" title="' . _T('app_button_new') . '">' . '<img src="images/jimmac/stock_new-16.png" border="0" width="16" height="16" alt="" /></a>'; // End of nav_menu_box for Agenda echo "</div>\n"; } // End of "navigation_menu_column" content echo "</div>\n\n\t\t\t\t<!-- The main content will be here - all the data, html forms, search results etc. -->\n\t\t\t\t<div id=\"main_column\">\n\t\t\t\t\n\t\t\t\t\t<!-- Start of 'main_column' content -->\n\t\t\t\t\t<h3 class=\"content_head\">"; if ($help_code) { echo '<span class="help_icon">' . lcm_help($help_code) . "</span> "; } echo $title; echo "</h3>\n\t\t\t\t\t<!-- [KM] Just a small experiment how the future breadcrumb will look like -->\n\t\t\t\t\t<!-- div id=\"breadcrumb\"><a href=\"#\" title=\"Test link\">Home</a> > <a href=\"#\" title=\"Test link\">Page1</a> > <a href=\"#\" title=\"Test link\">Subpage1</a> > Subsubpage1</div -->\n\t"; }