$result = lcm_query($q); lcm_page_start(_T('title_case_add_org')); show_context_start(); show_context_case_title($case); show_context_case_involving($case); show_context_end(); // Get the number of rows in the result $number_of_rows = lcm_num_rows($result); // 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") . "'>";
function loadCases($list_pos = 0) { global $prefs; $q = "SELECT clo.id_case, c.*\n\t\t\t\tFROM lcm_case_client_org as clo, lcm_case as c\n\t\t\t\tWHERE clo.id_client = " . $this->getDataInt('id_client', '__ASSERT__') . "\n\t\t\t\tAND clo.id_case = c.id_case "; // Sort cases by creation date $case_order = 'DESC'; if (_request('case_order') == 'ASC' || _request('case_order') == 'DESC') { $case_order = _request('case_order'); } $q .= " ORDER BY c.date_creation " . $case_order; $result = lcm_query($q); $number_of_rows = lcm_num_rows($result); if ($list_pos >= $number_of_rows) { return; } // Position to the page info start if ($list_pos > 0) { if (!lcm_data_seek($result, $list_pos)) { lcm_panic("Error seeking position {$list_pos} in the result"); } } if (lcm_num_rows($result)) { for ($cpt = 0; $cpt < $prefs['page_rows'] && ($row = lcm_fetch_array($result)); $cpt++) { array_push($this->cases, $row); } } }
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"; } }
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); } }