Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 function printCases($find_case_string = '')
 {
     global $prefs;
     $cpt = 0;
     $my_list_pos = intval(_request('list_pos', 0));
     show_page_subtitle(_T('client_subtitle_cases'), 'cases_participants');
     echo "<p class=\"normal_text\">\n";
     show_listcase_start();
     for ($cpt = 0, $this->getCaseStart(); !$this->getCaseDone() && $cpt < $prefs['page_rows']; $cpt++) {
         $item = $this->getCaseIterator();
         show_listcase_item($item, $cpt, $find_case_string, 'javascript:;', 'onclick="getCaseInfo(' . $item['id_case'] . ')"');
     }
     if (!$cpt) {
         echo "No cases";
     }
     show_listcase_end($my_list_pos, $this->getCaseTotal());
     echo "</p>\n";
     echo "</fieldset>\n";
 }
Exemplo n.º 3
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)) {
             lcm_panic("Error seeking position {$list_pos} in the result");
         }
     }
     if (lcm_num_rows($result)) {
         echo '<fieldset class="info_box">' . "\n";
         show_page_subtitle(_T('client_subtitle_cases'), 'cases_participants');
         echo "<p class=\"normal_text\">\n";
         show_listcase_start();
         for ($cpt = 0; $i < $prefs['page_rows'] && ($row1 = lcm_fetch_array($result)); $cpt++) {
             show_listcase_item($row1, $cpt);
         }
         show_listcase_end($list_pos, $number_of_rows);
         echo "</p>\n";
         echo "</fieldset>\n";
     }
     break;
     //
     // Client attachments
     //
 //
 // Client attachments
 //
 case 'attachments':
     echo '<fieldset class="info_box">';
     show_page_subtitle(_T('client_subtitle_attachments'), 'tools_documents');