Exemple #1
0
 function LcmFollowup($id_fu = 0, $id_case = 0)
 {
     $id_fu = intval($id_fu);
     $id_case = intval($id_case);
     $this->data = array();
     if ($id_fu > 0) {
         $query = "SELECT fu.*, a.name_first, a.name_middle, a.name_last, " . lcm_query_subst_time('fu.date_start', 'fu.date_end') . " as length\n\t\t\t\t\tFROM lcm_followup as fu, lcm_author as a\n\t\t\t\t\tWHERE id_followup = {$id_fu}\n\t\t\t\t\t  AND fu.id_author = a.id_author";
         $result = lcm_query($query);
         if ($row = lcm_fetch_array($result)) {
             foreach ($row as $key => $val) {
                 $this->data[$key] = $val;
             }
         }
     } else {
         if ($id_case > 0) {
             $this->data['id_case'] = $id_case;
         }
         // Dates
         $this->data['date_start'] = date('Y-m-d H:i:s');
         // '2004-09-16 16:32:37'
         $this->data['date_end'] = date('Y-m-d H:i:s');
         // '2004-09-16 16:32:37'
         // Set appointment start/end/reminder times to current time
         $this->data['app_start_time'] = date('Y-m-d H:i:s');
         $this->data['app_end_time'] = date('Y-m-d H:i:s');
         $this->data['app_reminder'] = date('Y-m-d H:i:s');
         if (isset($_REQUEST['stage'])) {
             $this->data['new_stage'] = _request('stage');
         }
         if (isset($_REQUEST['type'])) {
             $this->data['type'] = _request('type');
         }
     }
     // If any, populate form values submitted
     foreach ($_REQUEST as $key => $value) {
         $nkey = $key;
         if (substr($key, 0, 3) == 'fu_') {
             $nkey = substr($key, 3);
         }
         $this->data[$nkey] = clean_input(_request($key));
     }
     // If any, populate with session variables (for error reporting)
     if (isset($_SESSION['form_data']) && count($_SESSION['errors'])) {
         foreach ($_SESSION['form_data'] as $key => $value) {
             $nkey = $key;
             if (substr($key, 0, 3) == 'fu_') {
                 $nkey = substr($key, 3);
             }
             $this->data[$nkey] = clean_input(_session($key));
         }
     }
     // date_start
     if (get_datetime_from_array($_SESSION['form_data'], 'start', 'start', -1, false) != -1) {
         $this->data['date_start'] = get_datetime_from_array($_SESSION['form_data'], 'start', 'start', '', false);
     }
 }
Exemple #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";
     }
 }
Exemple #3
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);
     }
 }
Exemple #4
0
	for more details.

	You should have received a copy of the GNU General Public License along
	with this program; if not, write to the Free Software Foundation, Inc.,
	59 Temple Place, Suite 330, Boston, MA  02111-1307, USA

	$Id: fu_det.php,v 1.39 2007/03/26 16:14:32 mlutfy Exp $
*/
include 'inc/inc.php';
include_lcm('inc_acc');
include_lcm('inc_filters');
include_lcm('inc_obj_fu');
if (isset($_GET['followup'])) {
    $followup = intval($_GET['followup']);
    // Fetch the details on the specified follow-up
    $q = "SELECT fu.*, a.name_first, a.name_middle, a.name_last, " . lcm_query_subst_time('fu.date_start', 'fu.date_end') . " as length\n\t\tFROM lcm_followup as fu, lcm_author as a\n\t\tWHERE id_followup = {$followup}\n\t\t\tAND fu.id_author = a.id_author";
    $result = lcm_query($q);
    if ($row = lcm_fetch_array($result)) {
        foreach ($row as $key => $value) {
            $fu_data[$key] = $value;
        }
    } else {
        die("There's no such follow-up!");
    }
} else {
    die("Which follow-up?");
}
// For 'edit case' button + 'undelete' message
$case_allow_modif = read_meta('case_allow_modif');
$edit = allowed($fu_data['id_case'], 'e');
$admin = allowed($fu_data['id_case'], 'a');
Exemple #5
0
    if ($prefs['case_owner'] == 'public') {
        $q .= " c.public = 1 OR ";
    }
    // [ML] XXX FIXME TEMPORARY PATCH
    // 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