コード例 #1
0
ファイル: inc_obj_exp.php プロジェクト: nyimbi/legalcase
 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";
     }
 }
コード例 #2
0
ファイル: inc_filters.php プロジェクト: nyimbi/legalcase
function get_fu_description($item, $make_short = true)
{
    if (!is_array($item)) {
        lcm_debug("get_fu_description: parameter is not an array.");
        return '';
    }
    global $prefs;
    global $fu_desc_len;
    // configure via my_options.php with $GLOBALS['fu_desc_len'] = NNN;
    $short_description = '';
    // Set the length of short followup title (was: wide = 48, narrow = 115)
    $title_length = isset($fu_desc_len) && $fu_desc_len > 0 ? $fu_desc_len : 256;
    if ($item['type'] == 'assignment' && is_numeric($item['description'])) {
        $res1 = lcm_query("SELECT * FROM lcm_author WHERE id_author = " . $item['description']);
        $author1 = lcm_fetch_array($res1);
        $short_description = _T('case_info_author_assigned', array('name' => get_person_name($author1)));
    } elseif ($item['type'] == 'unassignment' && is_numeric($item['description'])) {
        $res1 = lcm_query("SELECT * FROM lcm_author WHERE id_author = " . $item['description']);
        $author1 = lcm_fetch_array($res1);
        $short_description = _T('case_info_author_unassigned', array('name' => get_person_name($author1)));
    } elseif ($item['type'] == 'stage_change' || is_status_change($item['type'])) {
        $tmp = lcm_unserialize($item['description']);
        // for backward compatibility, make it optional
        if ($item['case_stage']) {
            $short_description = _Tkw('stage', $item['case_stage']);
        }
        if ($tmp['description']) {
            $short_description .= " / " . $tmp['description'];
        }
        if ($tmp['result'] || $tmp['conclusion']) {
            $short_description .= "\n" . _Ti('fu_input_conclusion');
        }
        if ($tmp['result']) {
            $short_description .= _Tkw('_crimresults', $tmp['result']) . "/";
        }
        if ($tmp['conclusion']) {
            $short_description .= _Tkw('conclusion', $tmp['conclusion']);
        }
        if ($tmp['sentence']) {
            $short_description .= "\n" . _Ti('fu_input_sentence') . _Tkw('sentence', $tmp['sentence'], array('currency' => read_meta('currency')));
        }
        if ($tmp['sentence_val']) {
            $short_description .= ": " . $tmp['sentence_val'];
        }
    } else {
        if ($item['description']) {
            if (!$make_short || strlen(lcm_utf8_decode($item['description'])) < $title_length) {
                $short_description = $item['description'];
            } else {
                $short_description = substr($item['description'], 0, $title_length) . '...';
            }
            $short_description = clean_output($short_description);
        } else {
            $short_description = _T('fu_info_emptydesc');
        }
    }
    $short_description = nl2br($short_description);
    if (empty($short_description)) {
        $short_description = _T('info_not_available');
    }
    return $short_description;
}
コード例 #3
0
ファイル: app_det.php プロジェクト: nyimbi/legalcase
 $res_fu = lcm_query($q);
 if (lcm_num_rows($res_fu) > 0) {
     // Show parent followup title
     $fu = lcm_fetch_array($res_fu);
     $short_description = get_fu_description($fu);
     echo '<br />Consequent to:' . ' <a class="content_link" href="fu_det.php?followup=' . $fu['id_followup'] . '">' . $short_description . "</a><br />\n";
     // TRAD
 }
 // Show child followup
 $q = "SELECT lcm_app_fu.id_followup,lcm_followup.description FROM lcm_app_fu,lcm_followup\n\t\t\tWHERE lcm_app_fu.id_app=" . $row['id_app'] . "\n\t\t\t\tAND lcm_app_fu.id_followup=lcm_followup.id_followup\n\t\t\t\tAND lcm_app_fu.relation='child'";
 $res_fu = lcm_query($q);
 if (lcm_num_rows($res_fu) > 0) {
     // Show child followup title
     $fu = lcm_fetch_array($res_fu);
     $title_length = $prefs['screen'] == "wide" ? 48 : 115;
     if (strlen(lcm_utf8_decode($fu['description'])) < $title_length) {
         $short_description = $fu['description'];
     } else {
         $short_description = substr($fu['description'], 0, $title_length) . '...';
     }
     echo '<br />Resulting followup:' . ' <a href="fu_det.php?followup=' . $fu['id_followup'] . '">' . $short_description;
     // TRAD
 } else {
     if ($ac['w']) {
         // Show create followup from appointment
         echo '<br /><a href="edit_fu.php?case=' . $row['id_case'] . '&amp;app=' . $row['id_app'] . '" class="create_new_lnk">Create new followup from this appointment';
         // TRAD
     }
 }
 echo "</a><br />\n";
 // Show link back to the case details
コード例 #4
0
ファイル: import_db.php プロジェクト: nyimbi/legalcase
	or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
	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: import_db.php,v 1.16 2006/09/14 19:36:21 mlutfy Exp $
*/
include 'inc/inc.php';
include_lcm('inc_filters');
include_lcm('inc_conditions');
define('DIR_BACKUPS', isset($_SERVER['LcmDataDir']) ? $_SERVER['LcmDataDir'] : addslashes(getcwd()) . '/inc/data');
define('DIR_BACKUPS_PREFIX', DIR_BACKUPS . '/db-');
define('DATA_EXT_NAME', '.csv');
define('DATA_EXT_LEN', strlen(lcm_utf8_decode(DATA_EXT_NAME)));
if (!isset($_SESSION['errors'])) {
    $_SESSION['errors'] = array();
}
$tabs = array(array('name' => _T('archives_tab_export'), 'url' => 'export_db.php'), array('name' => _T('archives_tab_import'), 'url' => 'import_db.php'));
function show_import_form()
{
    lcm_page_start(_T('title_archives'), '', '', 'archives_import');
    global $tabs;
    show_tabs_links($tabs, 1);
    lcm_bubble('archive_restore');
    // Show the errors (if any)
    echo show_all_errors($_SESSION['errors']);
    // Upload backup form
    echo '<form enctype="multipart/form-data" action="import_db.php" method="post">' . "\n";
    echo '<input type="hidden" name="action" value="upload_file" />' . "\n";
コード例 #5
0
ファイル: inc_auth_db.php プロジェクト: nyimbi/legalcase
 function newusername($id_author, $old_username, $new_username, $author_session = 0)
 {
     $this->error = "";
     if ($this->is_newusername_allowed($id_author, $old_username, $author_session) == false) {
         return false;
     }
     // Check for username size
     if (strlen(lcm_utf8_decode($new_username)) < 3) {
         $this->error = _T('login_warning_too_short');
         return false;
     }
     // Check if username is not already taken
     $query = "SELECT username\n\t\t\t\t\tFROM lcm_author\n\t\t\t\t\tWHERE username = '******'";
     $result = lcm_query($query);
     if ($row = lcm_fetch_array($result)) {
         $this->error = _T('login_warning_already_exists ');
         return false;
     }
     $query = "UPDATE lcm_author\n\t\t\t\t\tSET username = '******'\n\t\t\t\t\tWHERE id_author = {$id_author}";
     lcm_query($query);
     // Check for errors (duplicates, format, etc.)
     if (lcm_sql_errno()) {
         $this->error = lcm_sql_error();
         lcm_log("newusername: " . $this->error);
         return false;
     }
     return true;
 }
コード例 #6
0
ファイル: upd_author.php プロジェクト: nyimbi/legalcase
    }
}
//
// Start SQL query
//
$fl = "date_update = NOW()";
// First name must have at least one character
if (strlen(lcm_utf8_decode(_session('name_first'))) < 1) {
    $_SESSION['errors']['name_first'] = _T('person_input_name_first') . ' ' . _T('warning_field_mandatory');
} else {
    $fl .= ", name_first = '" . _session('name_first') . "'";
}
// Middle name can be empty
$fl .= ", name_middle = '" . _session('name_middle') . "'";
// Last name must have at least one character
if (!strlen(lcm_utf8_decode(_session('name_last')))) {
    $_SESSION['errors']['name_last'] = _T('person_input_name_last') . ' ' . _T('warning_field_mandatory');
} else {
    $fl .= ", name_last = '" . _session('name_last') . "'";
}
// Author status can only be changed by admins
if ($author_session['status'] == 'admin') {
    $fl .= ", status = '" . _session('status') . "'";
}
if (_session('id_author') > 0) {
    $q = "UPDATE lcm_author \n\t\t\tSET {$fl} \n\t\t\tWHERE id_author = " . _session('id_author');
    $result = lcm_query($q);
} else {
    if (count($errors)) {
        header("Location: edit_author.php?author=0");
        exit;