예제 #1
0
function show_export_form_partial()
{
    //
    // New backup
    //
    echo "<fieldset class='info_box'>\n";
    show_page_subtitle(_T('archives_subtitle_new'), 'archives_export', 'newbackup');
    echo "<form action='export_db.php' method='post'>\n";
    echo '<p class="normal_text">' . _T('archives_info_what_is_backup') . "</p>\n";
    echo '<p><a class="exp_lnk" href="export_db.php?action=export">' . _T('archives_button_new') . "</a></p>\n";
    echo "</form>\n";
    echo "</fieldset>\n";
    //
    // Existing backups
    //
    echo "<fieldset class='info_box'>\n";
    echo "<a name='listbk'></a>\n";
    show_page_subtitle(_T('archives_subtitle_previously_made'), 'archives_export', 'delbackup');
    $storage = opendir(DIR_BACKUPS);
    $html = "";
    while ($file = readdir($storage)) {
        if (is_dir(DIR_BACKUPS . "/{$file}") && strpos($file, 'db-') === 0) {
            $file = substr($file, 3);
            $css = 'tbl_cont_' . ($cpt++ % 2 ? "dark" : "light");
            $html .= "<tr>\n";
            $html .= '<td class="' . $css . '">' . $file . "</td>\n";
            $html .= '<td nowrap="nowrap" width="1%" class="' . $css . '">' . get_delete_box($file, "rem_file", "test") . "</td>\n";
            $html .= "</tr>\n";
        } elseif (is_file(DIR_BACKUPS . "/{$file}") && strpos($file, 'db-') === 0) {
            $file = substr($file, 3);
            $css = 'tbl_cont_' . ($cpt++ % 2 ? "dark" : "light");
            $html .= "<tr>\n";
            $html .= '<td class="' . $css . '">';
            $html .= '<a class="content_link" href="export_db.php?action=download&file=' . $file . '">' . $file . '</a>';
            $html .= ' (' . filesize_in_bytes(DIR_BACKUPS_PREFIX . $file) . ')';
            $html .= "</td>\n";
            $html .= '<td nowrap="nowrap" width="1%" class="' . $css . '">' . get_delete_box($file, "rem_file", "test") . "</td>\n";
            $html .= "</tr>\n";
        }
    }
    if ($html) {
        echo '<p class="normal_text">' . _T('archives_info_how_to_download') . "</p>\n";
        echo '<form action="export_db.php" method="post">' . "\n";
        echo '<input type="hidden" name="action" value="rem_file" />' . "\n";
        echo '<div style="height: 250px; overflow: auto;">';
        echo '<table border="0" align="center" class="tbl_usr_dtl" width="99%">' . "\n";
        echo $html;
        echo "</table>\n";
        echo "</div>\n";
        echo '<div align="right" style="visibility: hidden;">';
        echo '<input type="submit" name="submit" id="btn_delete" value="' . _T('button_delete') . '" class="search_form_btn" />';
        echo "</div>\n";
        echo "</form>\n";
    } else {
        echo '<p class="normal_text">' . _T('archives_info_no_previous') . "</p>\n";
    }
    echo "</fieldset>\n";
}
예제 #2
0
 function printEdit()
 {
     // Get site preferences
     $client_name_middle = read_meta('client_name_middle');
     $client_citizen_number = read_meta('client_citizen_number');
     $client_civil_status = read_meta('client_civil_status');
     $client_income = read_meta('client_income');
     $meta_date_birth = read_meta('client_date_birth');
     echo '<table width="99%" border="0" align="center" cellpadding="5" cellspacing="0" class="tbl_usr_dtl">' . "\n";
     if ($this->getDataInt('id_client')) {
         echo "<tr><td>" . _T('client_input_id') . "</td>\n";
         echo "<td>" . $this->getDataInt('id_client') . '<input type="hidden" name="id_client" value="' . $this->getDataInt('id_client') . '" /></td></tr>' . "\n";
     }
     // Client name
     echo '<tr><td>' . f_err_star('name_first') . _T('person_input_name_first') . '</td>' . "\n";
     echo '<td><input name="name_first" value="' . clean_output($this->getDataString('name_first')) . '" class="search_form_txt" /></td></tr>' . "\n";
     // [ML] always show middle name, if any, no matter the configuration
     if ($this->getDataString('name_middle') || substr($client_name_middle, 0, 3) == 'yes') {
         echo '<tr><td>' . f_err_star('name_middle') . _T('person_input_name_middle') . '</td>' . "\n";
         echo '<td><input name="name_middle" value="' . clean_output($this->getDataString('name_middle')) . '" class="search_form_txt" /></td></tr>' . "\n";
     }
     echo '<tr><td>' . f_err_star('name_last') . _T('person_input_name_last') . '</td>' . "\n";
     echo '<td><input name="name_last" value="' . clean_output($this->getDataString('name_last')) . '" class="search_form_txt" /></td></tr>' . "\n";
     if (substr($meta_date_birth, 0, 3) == 'yes') {
         echo "<tr>\n";
         echo "<td>" . f_err_star('date_birth') . _Ti('person_input_date_birth') . "</td>\n";
         echo "<td>" . get_date_inputs('date_birth', $this->getDataString('date_birth'), true) . "</td>\n";
         echo "</tr>\n";
     }
     echo '<tr><td>' . f_err_star('gender') . _T('person_input_gender') . '</td>' . "\n";
     echo '<td><select name="gender" class="sel_frm">' . "\n";
     $opt_sel_male = $opt_sel_female = $opt_sel_unknown = '';
     if ($this->getDataString('gender') == 'male') {
         $opt_sel_male = 'selected="selected" ';
     } else {
         if ($this->getDataString('gender') == 'female') {
             $opt_sel_female = 'selected="selected" ';
         } else {
             $opt_sel_unknown = 'selected="selected" ';
         }
     }
     echo '<option ' . $opt_sel_unknown . 'value="unknown">' . _T('info_not_available') . "</option>\n";
     echo '<option ' . $opt_sel_male . 'value="male">' . _T('person_input_gender_male') . "</option>\n";
     echo '<option ' . $opt_sel_female . 'value="female">' . _T('person_input_gender_female') . "</option>\n";
     echo "</select>\n";
     echo "</td></tr>\n";
     if ($this->getDataString('id_client')) {
         echo "<tr>\n";
         echo '<td>' . _Ti('time_input_date_creation') . '</td>';
         echo '<td>' . format_date($this->getDataString('date_creation'), 'full') . '</td>';
         echo "</tr>\n";
     }
     if (substr($client_citizen_number, 0, 3) == 'yes') {
         echo "<tr>\n";
         echo '<td>' . f_err_star('citizen_number') . _T('person_input_citizen_number') . '</td>';
         echo '<td><input name="citizen_number" value="' . clean_output($this->getDataString('citizen_number')) . '" class="search_form_txt" /></td>';
         echo "</tr>\n";
     }
     if (substr($client_civil_status, 0, 3) == 'yes') {
         echo "<tr>\n";
         echo '<td>' . f_err_star('civil_status') . _Ti('person_input_civil_status') . '</td>';
         echo '<td>';
         echo '<select name="civil_status">';
         if (!$this->getDataInt('id_client')) {
             echo '<option value=""></option>';
         }
         $kwg = get_kwg_from_name('civilstatus');
         $all_kw = get_keywords_in_group_name('civilstatus');
         // A bit overkill, but if the user made the error of not entering
         // a valid civil_status, make sure that the field stays empty
         if (!$this->getDataString('civil_status') || !count($_SESSION['errors'])) {
             if ($this->getDataInt('id_client')) {
                 $this->data['civil_status'] = $all_kw['unknown']['name'];
             } else {
                 $this->data['civil_status'] = $kwg['suggest'];
             }
         }
         foreach ($all_kw as $kw) {
             $sel = $this->getDataString('civil_status') == $kw['name'] ? ' selected="selected"' : '';
             echo '<option value="' . $kw['name'] . '"' . $sel . '>' . _T($kw['title']) . '</option>';
         }
         echo '</select>';
         echo '</td>';
         echo "</tr>\n";
     }
     if (substr($client_income, 0, 3) == 'yes') {
         echo "<tr>\n";
         echo '<td>' . f_err_star('income') . _Ti('person_input_income') . '</td>';
         echo '<td>';
         echo '<select name="income">';
         if (!$this->getDataInt('id_client')) {
             echo '<option value=""></option>';
         }
         $kwg = get_kwg_from_name('income');
         $all_kw = get_keywords_in_group_name('income');
         if (!$this->getDataString('income') && !count($_SESSION['errors'])) {
             if ($this->getDataInt('id_client')) {
                 $this->data['income'] = $all_kw['unknown']['name'];
             } else {
                 $this->data['income'] = $kwg['suggest'];
             }
         }
         foreach ($all_kw as $kw) {
             $sel = $this->getDataString('income') == $kw['name'] ? ' selected="selected"' : '';
             echo '<option value="' . $kw['name'] . '"' . $sel . '>' . _T($kw['title']) . '</option>';
         }
         echo '</select>';
         echo '</td>';
         echo "</tr>\n";
     }
     //
     // Keywords, if any
     //
     show_edit_keywords_form('client', $this->getDataInt('id_client'));
     // Notes
     echo "<tr>\n";
     echo "<td>" . f_err_star('client_notes') . _Ti('client_input_notes') . "</td>\n";
     echo '<td><textarea name="client_notes" id="input_client_notes" class="frm_tarea" rows="3" cols="60">' . clean_output($this->getDataString('notes')) . "</textarea>\n" . "</td>\n";
     echo "</tr>\n";
     //
     // Contacts (e-mail, phones, etc.)
     //
     echo "<tr>\n";
     echo '<td colspan="2" align="center" valign="middle">';
     show_page_subtitle(_T('client_subtitle_contacts'));
     echo '</td>';
     echo "</tr>\n";
     show_edit_contacts_form('client', $this->getDataInt('id_client'));
     echo "</table>\n";
 }
예제 #3
0
$obj_case = new LcmCaseInfoUI($id_case);
$obj_case->printEdit();
echo "</div>\n";
/* div case_data */
echo "<script type=\"text/javascript\">\n\t\tautocomplete('casesearchkey', 'autocomplete-case-popup', 'ajax.php', 'autocomplete-case-data', 'case_data')\n\t</script>\n";
//
// Follow-up data (only for new case, not edit case)
//
if (!$id_case) {
    echo '<p class="normal_text">';
    echo '<input type="checkbox"' . isChecked(_session('add_fu')) . 'name="add_fu" id="box_new_followup" onclick="display_block(\'new_followup\', \'flip\')" />';
    echo '<label for="box_new_followup">' . "Add a follow-up to the case" . '</label>';
    // TRAD
    echo "</p>\n";
    echo '<div id="new_followup" ' . (_session('add_fu') ? '' : ' style="display: none;"') . '>';
    show_page_subtitle("Follow-up information", 'followups_intro');
    // TRAD
    echo '<div id="autocomplete-fu-alt">';
    $fu = new LcmFollowupInfoUI();
    $fu->printEdit();
    echo "</div>\n";
    echo "</div>\n";
}
echo '<p><button name="submit" type="submit" value="submit" class="simple_form_btn">' . _T('button_validate') . "</button></p>\n";
echo '<input type="hidden" name="admin" value="' . $_SESSION['form_data']['admin'] . "\" />\n";
echo '<input type="hidden" name="ref_edit_case" value="' . $_SESSION['form_data']['ref_edit_case'] . "\" />\n";
echo "</form>\n\n";
// Reset error messages and form data
$_SESSION['errors'] = array();
$_SESSION['case_data'] = array();
// DEPRECATED
예제 #4
0
function show_all_contacts($type_person, $id_of_person)
{
    global $author_session;
    $show_emails = !(read_meta('hide_emails') && $author_session['status'] != 'admin');
    $contacts = get_contacts($type_person, $id_of_person);
    $html = "";
    $i = 0;
    if (!count($contacts)) {
        return;
    }
    show_page_subtitle(_T('generic_subtitle_contacts'));
    echo '<table border="0" class="tbl_usr_dtl" width="100%">' . "\n";
    foreach ($contacts as $c) {
        // Check if the contact is an e-mail
        echo "<tr>\n";
        echo "<td class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>" . _T($c['title']) . ":</td>\n";
        echo "<td class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>";
        if ($show_emails && strpos($c['name'], 'email') === 0) {
            echo '<a href="mailto:' . $c['value'] . '" class="content_link">' . $c['value'] . '</a></td>\\n';
        } else {
            echo "<td class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>" . $c['value'] . "</td>\n";
        }
        echo '<td class="tbl_cont_' . ($i % 2 ? 'dark' : 'light') . '">' . ($c['date_update'] != null ? format_date($c['date_update'], 'date_short') : '') . "</td>\n";
        echo "</tr>\n";
        $i++;
    }
    echo "</table>\n";
    echo "<br />\n";
}
예제 #5
0
            $exp_list->setSearchTerm($find_exp_string);
            $exp_list->setCase($case);
            $exp_list->start();
            $exp_list->printList();
            $exp_list->finish();
            echo '<p><a href="edit_exp.php?case=' . $case . '" class="create_new_lnk">' . _T('expense_button_new') . "</a></p>\n";
            break;
            //
            // Case attachments
            //
        //
        // Case attachments
        //
        case 'attachments':
            echo '<fieldset class="info_box">';
            show_page_subtitle(_T('case_subtitle_attachments'), 'tools_documents');
            echo '<form enctype="multipart/form-data" action="attach_file.php" method="post">' . "\n";
            echo '<input type="hidden" name="case" value="' . $case . '" />' . "\n";
            // List of attached files
            show_attachments_list('case', $case);
            // Attach new file form
            if ($add) {
                show_attachments_upload('case', $case, $_SESSION['user_file']['name'], $_SESSION['user_file']['description']);
            }
            echo '<input type="submit" name="submit" value="' . _T('button_validate') . '" class="search_form_btn" />' . "\n";
            echo "</form>\n";
            echo "</fieldset>\n";
            $_SESSION['user_file'] = array();
            break;
    }
} else {
예제 #6
0
if (!($row = lcm_fetch_array($result))) {
    die("There is no such appointment.");
}
lcm_page_start(_T('title_app_view') . ' ' . $row['title'], '', '', 'tools_agenda');
echo '<fieldset class="info_box">' . "\n";
echo '<p class="normal_text">' . "\n";
echo _Ti('app_input_title') . $row['title'] . "<br />\n";
echo _Ti('app_input_type') . _Tkw('appointments', $row['type']) . "<br />\n";
if ($row['hidden'] == 'Y') {
    echo '<p class="normal_text"><strong>' . _T('app_info_is_deleted') . "</strong>";
    if ($ac['a']) {
        echo " " . _T('app_info_is_deleted2');
    }
    echo "</p>\n";
}
show_page_subtitle(_T('generic_subtitle_general'), 'tools_agenda');
echo _Ti('app_input_description') . nl2br($row['description']) . "<br />\n";
echo "<br />\n";
echo _Ti('time_input_date_start') . format_date($row['start_time'], 'short');
$year_for_cal = "&annee=" . annee($row['start_time']) . "&mois=" . mois($row['start_time']) . "&jour=" . journum($row['start_time']);
// day
echo ' ' . http_href_img("calendar.php?type=jour" . $year_for_cal, 'cal-today.gif', '', _T('app_info_see_cal_for_day_tooltip'));
echo "<br />\n";
/* [ML] removing: not really useful for now 
	$end_time = vider_date($row['end_time']);
	$reminder = vider_date($row['reminder']);
	if ($prefs['time_intervals'] == 'absolute') {
		echo _Ti('time_input_date_end') . format_date($row['end_time'], 'short') . "<br />\n";
		echo _Ti('app_input_reminder') . format_date($row['reminder'], 'short') . "<br />\n";
	} else {
		$duration = ($end_time ? strtotime($row['end_time']) - strtotime($row['start_time']) : 0);
예제 #7
0
// Contacts (e-mail, phones, etc.)
//
echo "<tr>\n";
echo '<td colspan="2" align="center" valign="middle" class="heading">';
show_page_subtitle(_T('client_subtitle_contacts'), 'contacts');
echo '</td>';
echo "</tr>\n";
show_edit_contacts_form('author', $user['id_author']);
//
// LOGIN INFO
//
?>
		<tr>
			<td colspan="2" align="center" valign="middle" class="heading">
<?php 
show_page_subtitle(_T('authoredit_subtitle_connectionidentifiers'), 'author_edit');
?>
			</td>
		</tr>
		<tr><td align="left" valign="top"><?php 
echo f_err_star('username') . _T('authoredit_input_username');
?>
</td>
			<td align="left" valign="top">

		<?php 
global $author_session;
$class_auth = 'Auth_db';
include_lcm('inc_auth_db');
$auth = new $class_auth();
if (!$auth->init()) {
예제 #8
0
echo '<p><a href="edit_rep.php?rep=0" class="create_new_lnk">' . _T('rep_button_new') . "</a></p>\n";
//
// Custom reports (plugins)
//
$custom_reports = array();
$handle = opendir("inc/config/custom/reports");
while (($f = readdir($handle)) != '') {
    if (is_file("inc/config/custom/reports/" . $f)) {
        // matches: custom/reports/alpha-num_name.php
        if (preg_match("/^([_a-zA-Z0-9]+)\\.php/", $f, $regs)) {
            $custom_reports[] = $regs[1];
        }
    }
}
if (count($custom_reports)) {
    show_page_subtitle("Custom reports", 'reports_custom');
    // TRAD
    echo '<p class="normal_text">';
    $headers = array();
    $headers[0]['title'] = _Th('rep_input_title');
    // $headers[0]['order'] = 'order_ctitle';
    // $headers[0]['default'] = 'ASC';
    show_list_start($headers);
    for ($i = 0; $i < $prefs['page_rows'] && $custom_reports[$i]; $i++) {
        echo "<tr><td class='tbl_cont_" . ($i % 2 ? "dark" : "light") . "'>";
        // TODO: how to extract name of report?
        // an 'include(report) + $report->get_name() would be overkill..
        echo '<a class="content_link" href="edit_rep.php?filecustom=' . $custom_reports[$i] . '">' . $custom_reports[$i] . '</a>';
        echo "</td>\n";
        echo "</tr>\n";
    }
예제 #9
0
 function printFollowups($show_filters = false)
 {
     $cpt = 0;
     $my_list_pos = intval(_request('list_pos', 0));
     show_page_subtitle(_T('case_subtitle_followups'), 'cases_followups');
     // Show filters (if not shown in ajaxed page)
     if ($show_filters) {
         // By default, show from "case creation date" to NOW().
         $link = new Link();
         $link->delVar('date_start_day');
         $link->delVar('date_start_month');
         $link->delVar('date_start_year');
         $link->delVar('date_end_day');
         $link->delVar('date_end_month');
         $link->delVar('date_end_year');
         echo $link->getForm();
         $date_end = get_datetime_from_array($_REQUEST, 'date_end', 'end', '0000-00-00 00:00:00');
         // date('Y-m-d H:i:s'));
         $date_start = get_datetime_from_array($_REQUEST, 'date_start', 'start', '0000-00-00 00:00:00');
         // $row['date_creation']);
         echo _Ti('time_input_date_start');
         echo get_date_inputs('date_start', $date_start);
         echo _Ti('time_input_date_end');
         echo get_date_inputs('date_end', $date_end);
         echo ' <button name="submit" type="submit" value="submit" class="simple_form_btn">' . _T('button_validate') . "</button>\n";
         echo "</form>\n";
         echo "<div style='margin-bottom: 4px;'>&nbsp;</div>\n";
         // FIXME patch for now (leave small space between filter and list)
     }
     show_listfu_start('general', false);
     for ($cpt = 0, $this->getFollowupStart(); !$this->getFollowupDone(); $cpt++) {
         $item = $this->getFollowupIterator();
         show_listfu_item($item, $cpt);
     }
     if (!$cpt) {
         echo "No followups";
     }
     // TRAD
     show_list_end($my_list_pos, $this->getFollowupTotal(), true);
 }
예제 #10
0
// Show the list of cases
//
echo '<p class="normal_text">' . "\n";
$case_list = new LcmCaseListUI();
$case_list->setSearchTerm($find_case_string);
$case_list->start();
$case_list->printList();
$case_list->finish();
echo "</p>\n";
echo '<p><a href="edit_case.php?case=0" class="create_new_lnk">' . _T('case_button_new') . "</a></p>\n";
echo '<p><a href="edit_client.php" class="create_new_lnk">' . _T('client_button_new') . "</a></p>\n";
//
// List of recent follow-ups
//
echo '<a name="fu"></a>' . "\n";
show_page_subtitle(_T('case_subtitle_recent_followups'));
echo '<p class="normal_text">' . "\n";
show_listfu_start('general');
$q = "SELECT fu.id_case, fu.id_followup, fu.date_start, fu.date_end, fu.type, fu.description, fu.case_stage,\n\t\t\tfu.hidden, a.name_first, a.name_middle, a.name_last, c.title\n\t\tFROM lcm_followup as fu, lcm_author as a, lcm_case as c \n\t\tWHERE fu.id_author = a.id_author \n\t\t  AND  c.id_case = fu.id_case ";
// Author of the follow-up
// START - Get list of cases on which author is assigned
$q_temp = "SELECT c.id_case\n\t\t\t\tFROM lcm_case_author as ca, lcm_case as c\n\t\t\t\tWHERE ca.id_case = c.id_case\n\t\t\t\t  AND ca.id_author = " . $author_session['id_author'];
if ($prefs['case_period'] < 1900) {
    // since X days
    // $q_temp .= " AND TO_DAYS(NOW()) - TO_DAYS(c.date_creation) < " . $prefs['case_period'];
    $q_temp .= " AND " . lcm_query_subst_time('c.date_creation', 'NOW()') . ' < ' . $prefs['case_period'] * 3600 * 24;
} else {
    // for year X
    // $q_temp .= " AND YEAR(date_creation) = " . $prefs['case_period'];
    $q_temp .= " AND " . lcm_query_trunc_field('c.date_creation', 'year') . ' = ' . $prefs['case_period'];
}
예제 #11
0
echo '<p><a href="run_rep.php?rep=' . $rep_info['id_report'] . '" class="run_lnk">' . _T('rep_button_run') . '</a>&nbsp;';
echo '<a href="run_rep.php?export=csv&amp;rep=' . $rep_info['id_report'] . '" class="exp_lnk">' . _T('rep_button_exportcsv') . '</a>';
echo "</p></fieldset>";
//
// Matrix line
//
echo '<a name="line"></a>' . "\n";
echo "<fieldset class='info_box'>";
show_page_subtitle(_T('rep_subtitle_line'), 'reports_edit', 'line');
show_report_field_edit('line', $rep_info);
echo "</fieldset>\n";
//
// Matrix column (Experimental)
//
echo '<a name="col"></a>' . "\n";
echo "<fieldset class='info_box'>";
show_page_subtitle(_T('rep_subtitle_column'), 'reports_edit', 'columns');
show_report_field_edit('col', $rep_info);
echo "</fieldset>\n";
//
// Report filters
//
echo '<a name="filter"></a>' . "\n";
echo "<fieldset class='info_box'>";
show_page_subtitle(_T('rep_subtitle_filters'), 'reports_edit', 'filters');
include_lcm('inc_conditions');
show_report_filters($rep, false);
echo "</fieldset>\n";
lcm_page_end();
// Clear errors
$_SESSION['errors'] = array();
예제 #12
0
function show_author_attachments($id_author)
{
    // List attachments of every type
    // TODO: if meta for hide_org is active, don't show them
    foreach (array('case', 'client', 'org') as $type) {
        show_page_subtitle(_T('menu_main_' . $type . 's'), 'tools_documents');
        show_attachments_list($type, 0, $id_author);
    }
}
예제 #13
0
function import_database($input_filename)
{
    global $tabs;
    $input_filename = clean_input($input_filename);
    $root = addslashes(getcwd());
    $dir = DIR_BACKUPS_PREFIX . $input_filename;
    if (file_exists($dir)) {
        if ($_POST['conf'] !== 'yes') {
            // Print confirmation form
            lcm_page_start(_T('title_archives'), '', '', 'archives_import');
            show_tabs_links($tabs, 1, true);
            echo "<fieldset class='info_box'>\n";
            show_page_subtitle(_T('generic_subtitle_warning'), 'archives_import');
            echo "<p class='normal_text'><img src='images/jimmac/icon_warning.gif' alt='' " . "align='right' height='48' width='48' />" . _T('archives_info_restore_will_delete') . "</p>\n";
            echo "<form action='import_db.php' method='post'>\n";
            echo '<input type="hidden" name="action" value="import" />' . "\n";
            echo "<button type='submit' class='simple_form_btn' name='conf' value='yes'>" . _T('info_yes') . "</button>\n";
            echo "<button type='submit' class='simple_form_btn' name='conf' value='no'>" . _T('info_no') . "</button>\n";
            echo "<input type='hidden' name='file' value='{$input_filename}' />\n";
            echo "<input type='hidden' name='restore_type' value='" . $_POST['restore_type'] . "' />\n";
            echo "</form>";
            echo "</fieldset\n>";
            lcm_page_end();
            return;
        }
    }
    // Get saved database version
    if (!($fh = fopen("{$dir}/db-version", 'r'))) {
        lcm_panic("System error: Could not open file '{$dir}/db-version");
    }
    $backup_db_version = intval(fread($fh, 10));
    fclose($fh);
    // For debugging - use another database
    //lcm_query("use lcm_new");
    // Recreate tables
    if ($_POST['restore_type'] == 'clean' || $backup_db_version < read_meta('lcm_db_version')) {
        // Open backup dir
        if (!($dh = opendir("{$dir}/"))) {
            lcm_panic("System error: Could not open directory '{$dir}'");
        }
        while ($file = readdir($dh)) {
            // Get table name
            $table = substr($file, 0, -10);
            // Add path to filename
            $file = "{$dir}/{$file}";
            if (strlen($file) > 10) {
                if (is_file($file) && substr($file, -10) === ".structure" && is_file("{$dir}/{$table}" . DATA_EXT_NAME)) {
                    // Clear the table
                    $q = "DROP TABLE IF EXISTS {$table}";
                    $result = lcm_query($q);
                    // Create table
                    $fh = fopen($file, 'r');
                    $q = fread($fh, filesize($file));
                    fclose($fh);
                    $result = lcm_query_restore_table($q);
                }
            }
        }
        closedir($dh);
        // Update lcm_db_version
        // [ML] This is rather useless because they will be overwritten when the
        // values are loaded (LOAD FILE), but I leave it just in case there are
        // obscur bugs (altough this will most likely generate strange bugs..)
        write_meta('lcm_db_version', $backup_db_version);
        if (!preg_match('/^MySQL (4\\.0|3\\.)/', lcm_sql_server_info())) {
            write_meta('db_utf8', 'yes');
        }
        write_metas();
    } else {
        if ($backup_db_version > read_meta('lcm_db_version')) {
            // Backup version newer than installed db version
            lcm_page_start(_T('title_archives'), '', '', 'archives_import');
            // Show tabs
            show_tabs_links($tabs, 1, true);
            // Show tab header
            echo "Version mismatch!\n";
            // TRAD
            echo "<fieldset class='info_box'>\n";
            echo "Backup database version is newer than the installed database.";
            // TRAD
            echo "</fieldset\n>";
            lcm_page_end();
            return;
        } else {
            // Backup and current db versions are equal
        }
    }
    //
    // Import data into database tables\
    //
    // Change backup dir permissions, so MySQL could read from it.
    chmod($dir, 0755);
    // Open backup dir
    if (!($dh = opendir("{$dir}/"))) {
        lcm_panic("System error: Could not open directory '{$dir}'");
    }
    while ($file = readdir($dh)) {
        // Get table name
        $table = substr($file, 0, -DATA_EXT_LEN);
        // Add path to filename
        $file = "{$dir}/{$file}";
        if (strlen($file) > 5) {
            // [ML] why?
            if (is_file($file) && substr($file, -DATA_EXT_LEN) === DATA_EXT_NAME) {
                // If restore_type='clean', clear the table
                if ($_POST['restore_type'] == 'clean') {
                    lcm_query("TRUNCATE TABLE {$table}");
                }
                $q = "LOAD DATA INFILE '{$file}' ";
                $q .= $_POST['restore_type'] == 'replace' ? 'REPLACE' : 'IGNORE';
                $q .= "\tINTO TABLE {$table}\n\t\t\t\t\tFIELDS TERMINATED BY ','\n\t\t\t\t\t\tOPTIONALLY ENCLOSED BY '\"'\n\t\t\t\t\t\tESCAPED BY '\\\\'\n\t\t\t\t\tLINES TERMINATED BY '\r\n'";
                $result = lcm_query($q);
            }
        }
    }
    closedir($dh);
    // Change backup dir permissions back
    chmod($dir, 0700);
    // Update lcm_db_version since we have overwritten lcm_meta
    write_meta('lcm_db_version', $backup_db_version);
    if ($_REQUEST['restore_type'] == 'clean') {
        if (!preg_match('/^MySQL (4\\.0|3\\.)/', lcm_sql_server_info())) {
            write_meta('db_utf8', 'yes');
        }
    }
    write_metas();
    lcm_page_start(_T('title_archives'), '', '', 'archives_import');
    // FIXME?
    show_tabs_links($tabs, 1, true);
    echo '<div class="sys_msg_box">' . "\n";
    show_page_subtitle("Import finished", 'archives_import');
    // FIXME TRAD?
    echo "Backup '{$input_filename}' was successfully imported into database.";
    // TRAD
    echo "</div\n>";
    lcm_page_end();
}
예제 #14
0
function get_filters_sql($report, $obj_type = '', $obj_name = '')
{
    $ret = "";
    $is_missing_filters = false;
    $my_filters = get_filters($report->getId(), $obj_type, $obj_name);
    $clauses = array();
    // Apply the filter values and check for missing values
    foreach ($my_filters as $f) {
        if ($f['value'] || isset($_REQUEST['filter_val' . $f['id_filter']]) || isset_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'], 'year_only') || isset_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . "_start", 'year_only') && isset_datetime_from_array($_REQUEST, 'filter_val' . $f['id_filter'] . "_end", 'year_only')) {
            $filter_sql = apply_filter($f);
            if ($filter_sql) {
                array_push($clauses, $filter_sql);
            }
        } else {
            // For now, we ignore filters without type (eq/lt/gt/..)
            // because it's a bit messy to allow input at runtime
            // (because of fields for filter value)
            if ($f['type']) {
                $is_missing_filters = true;
            }
        }
    }
    if ($is_missing_filters) {
        if (!($report->getOption('headers_sent') == 'yes')) {
            lcm_page_start(_T('title_rep_run') . " " . remove_number_prefix($rep_info['title']), '', '', 'report_intro');
        }
        show_page_subtitle(_T('rep_subtitle_filters'), 'reports_edit', 'filters');
        echo '<p class="normal_text">';
        include_lcm('inc_conditions');
        show_report_filters($report->getId(), true);
        echo "</p>\n";
        lcm_page_end();
        exit;
    }
    $ret1 = implode(" AND ", $clauses);
    return $ret1;
}
예제 #15
0
 function printGeneral($show_subtitle = true, $allow_edit = true)
 {
     if ($show_subtitle) {
         show_page_subtitle(_T('generic_subtitle_general'), 'cases_intro');
     }
     echo '<ul class="info">';
     // TODO: fix html
     // Author
     echo '<li>' . '<span class="label2">' . _Ti('case_input_author') . '</span>' . '<span class="value2">' . get_author_link($this->data) . '</span>' . "</li>\n";
     // Date start
     echo '<li>' . '<span class="label2">' . _Ti('time_input_date_start') . '</span>' . '<span class="value2">' . format_date($this->data['date_start']) . '</span>' . "</li>\n";
     // Date end
     echo '<li>' . '<span class="label2">' . _Ti('time_input_date_end') . '</span>' . '<span class="value2">' . format_date($this->data['date_end']) . '</span>' . "</li>\n";
     // Date length
     echo '<li>' . '<span class="label2">' . _Ti('time_input_length') . '</span>' . '<span class="value2">' . format_time_interval_prefs($this->data['length']) . '</span>' . "</li>\n";
     // FU type
     echo '<li>' . '<span class="label2">' . _Ti('fu_input_type') . '</span>' . '<span class="value2">' . _Tkw('followups', $this->data['type']) . '</span>' . "</li>\n";
     // Keywords
     show_all_keywords('followup', $this->getDataInt('id_followup'));
     // Conclusion for case/status change
     /* [ML] 2008-01-30 Should not be necessary, done by get_fu_description()
     		if ($this->data['type'] == 'status_change' || $this->data['type'] == 'stage_change') {
     			$tmp = lcm_unserialize($this->data['description']);
     
     			var_dump($tmp);
     
     			echo '<li>'
     				. '<span class="label2">' . _Ti('fu_input_conclusion') .  '</span>';
     
     			echo '<span class="value2">';
     		
     			if (read_meta('case_result') == 'yes' && $tmp['result'])
     				echo _Tkw('_crimresults', $tmp['result']) . "<br />\n";
     			
     			echo _Tkw('conclusion', $tmp['conclusion']) . '</span>';
     			echo "</li>\n";
     		
     			echo '<li>'
     				. '<span class="label2">' . _Ti('fu_input_sentence') . '</li>'
     				. '<span class="value2">' . _Tkw('sentence', $tmp['sentence']) . '</span>'
     				. "</li>\n";
     		}
     		*/
     // Description
     $desc = get_fu_description($this->data, false);
     echo '<li class="large">' . '<span class="label2">' . _Ti('fu_input_description') . '</span>' . '<span class="value2">' . $desc . '</span>' . "</li>\n";
     // Sum billed (if activated from policy)
     if ($this->show_sum_billed == 'yes') {
         echo '<li>' . '<span class="label2">' . _T('fu_input_sum_billed') . '</span>' . '<span class="value2">';
         echo format_money(clean_output($this->data['sumbilled']));
         $currency = read_meta('currency');
         echo htmlspecialchars($currency);
         echo '</span>';
         echo "</li>\n";
     }
     echo "</ul>\n";
 }
예제 #16
0
 function printComments($full_ui = true)
 {
     $cpt = 0;
     $my_list_pos = intval(_request('list_pos', 0));
     $obj_acc = new LcmExpenseAccess(0, 0, $this);
     if ($full_ui) {
         show_page_subtitle(_T('expenses_subtitle_comments'), 'expenses_comments');
     }
     if (!$obj_acc->getRead()) {
         echo '<p>' . "Access denied. You do not have the permission to view this information." . "</p>\n";
         // TRAD (make function!)
         return;
     }
     for ($cpt = 0, $this->getCommentStart(); !$this->getCommentDone(); $cpt++) {
         $id_comment = $this->getCommentIterator();
         $comment = new LcmExpenseCommentInfoUI($this->getDataInt('id_expense'), $id_comment);
         $comment->printGeneral();
     }
     if (!$cpt) {
         echo "<p>No comments</p>";
     }
     // TRAD
     // [ML] FIXME : show_list_end() had the habit of closing tables,
     // because everthing used to have tables. This is obviously wrong
     // and will be fixed when other lists are non-taled.
     echo "<table><tr><td></td></tr>\n";
     show_list_end($my_list_pos, $this->getCommentTotal());
     if ($full_ui) {
         if ($obj_acc->getEdit()) {
             echo '<p><a href="edit_exp.php?edit_comment=1&amp;expense=' . $this->getDataInt('id_expense') . '" class="edit_lnk">' . _T('expense_button_comment') . '</a></p>' . "\n";
         }
     }
 }
예제 #17
0
 function printEdit()
 {
     echo '<table width="99%" border="0" align="center" cellpadding="5" cellspacing="0" class="tbl_usr_dtl">' . "\n";
     // Organisation ID
     if ($this->getDataInt('id_org')) {
         echo "<tr>\n";
         echo "<td>" . _Ti('org_input_id') . "</td>\n";
         echo "<td>" . $this->getDataInt('id_org') . '<input type="hidden" name="id_org" value="' . $this->getDataInt('id_org') . '" />' . "</td>\n";
         echo "</tr>\n";
     }
     // Organisation name
     echo "<tr>\n";
     echo "<td>" . f_err_star('name') . _Ti('org_input_name') . "</td>\n";
     echo '<td><input name="name" value="' . clean_output($this->getDataString('name')) . '" class="search_form_txt" />' . "</td>\n";
     echo "</tr>\n";
     // Court registration number
     echo "<tr>\n";
     echo "<td>" . f_err_star('court_reg') . _Ti('org_input_court_reg') . "</td>\n";
     echo '<td><input name="court_reg" value="' . clean_output($this->getDataString('court_reg')) . '" class="search_form_txt" />' . "</td>\n";
     echo "</tr>\n";
     // Tax number
     echo "<tr>\n";
     echo "<td>" . f_err_star('tax_number') . _Ti('org_input_tax_number') . "</td>\n";
     echo '<td><input name="tax_number" value="' . clean_output($this->getDataString('tax_number')) . '" class="search_form_txt" />' . "</td>\n";
     echo "</tr>\n";
     // Statistical number
     echo "<tr>\n";
     echo "<td>" . f_err_star('stat_number') . _Ti('org_input_stat_number') . "</td>\n";
     echo '<td><input name="stat_number" value="' . clean_output($this->getDataString('stat_number')) . '" class="search_form_txt" />' . "</td>\n";
     echo "</tr>\n";
     // Creation date
     if ($this->getDataInt('id_org')) {
         echo "<tr>\n";
         echo '<td>' . _Ti('time_input_date_creation') . '</td>';
         echo '<td>' . format_date($this->getDataString('date_creation'), 'full') . '</td>';
         echo "</tr>\n";
     }
     //
     // Keywords, if any
     //
     show_edit_keywords_form('org', $this->getDataInt('id_org'));
     // Notes
     echo "<tr>\n";
     echo "<td>" . f_err_star('notes') . _Ti('org_input_notes') . "</td>\n";
     echo '<td><textarea name="notes" id="input_notes" class="frm_tarea" rows="3" cols="60">' . clean_output($this->getDataString('notes')) . "</textarea>\n" . "</td>\n";
     echo "</tr>\n";
     //
     // Contacts (e-mail, phones, etc.)
     //
     echo "<tr>\n";
     echo '<td colspan="2" align="center" valign="middle">';
     show_page_subtitle(_T('client_subtitle_contacts'));
     echo '</td>';
     echo "</tr>\n";
     show_edit_contacts_form('org', $this->getDataInt('id_org'));
     echo "</table>\n";
 }
예제 #18
0
    lcm_page_start(_T('title_expense_new'), '', '', 'expenses');
}
/* TODO
show_context_start();
show_context_case_title($case, 'followups');
show_context_case_involving($case);
*/
show_context_end();
// Show the errors (if any)
echo show_all_errors();
echo '<form action="upd_exp.php" method="post">' . "\n";
$id_expense = _request('expense', 0);
$id_comment = _request('c', 0);
$status = _request('new_exp_status');
if ($status || $id_comment || _request('edit_comment')) {
    $obj_exp = new LcmExpenseInfoUI($id_expense);
    $obj_exp->printGeneral(false);
    // with minimal UI (no edit button)
    show_page_subtitle(_T('expenses_subtitle_comment'), 'expenses_comment');
    $obj_comment = new LcmExpenseCommentInfoUI($id_expense, $id_comment);
    $obj_comment->printEdit();
} else {
    $obj_exp = new LcmExpenseInfoUI(_request('expense', 0));
    $obj_exp->printEdit();
}
echo '<button name="submit" type="submit" value="submit" class="simple_form_btn">' . _T('button_validate') . "</button>\n";
echo "</form>\n";
lcm_page_end();
// Clear the errors, in case user jumps to other 'edit' page
$_SESSION['errors'] = array();
$_SESSION['form_data'] = array();
예제 #19
0
         }
         echo "</tr>\n";
         echo "</table>\n";
         echo "</p>\n";
     }
     $foo = get_date_range_fields();
     echo $foo['html'];
     show_report_for_user($author, $foo['date_start'], $foo['date_end'], 'case');
     show_report_for_user($author, $foo['date_start'], $foo['date_end'], 'fu');
     show_report_for_user($author, $foo['date_start'], $foo['date_end'], 'agenda');
     break;
 case 'appointments':
     if (!allowed_author($author, 'r')) {
         die("Access denied");
     }
     show_page_subtitle(_T('author_subtitle_appointments', array('author' => get_person_name($author_data))), 'tools_agenda');
     $foo = get_date_range_fields();
     $date_start = $foo['date_start'];
     $date_end = $foo['date_end'];
     echo $foo['html'];
     echo "<p class=\"normal_text\">\n";
     $q = "SELECT ap.*\n\t\t\t\t\tFROM lcm_author_app as aa, lcm_app as ap\n\t\t\t\t\tWHERE aa.id_app = ap.id_app\n\t\t\t\t\t\tAND UNIX_TIMESTAMP(start_time) >= UNIX_TIMESTAMP('" . $date_start . "') ";
     if ($date_end != "-1") {
         $q .= " AND UNIX_TIMESTAMP(end_time) <= UNIX_TIMESTAMP('" . $date_end . "') ";
     }
     $q .= " AND aa.id_author = " . $GLOBALS['author_session']['id_author'];
     // Sort agenda by date/time of the appointments
     $order = 'DESC';
     if (isset($_REQUEST['order'])) {
         if ($_REQUEST['order'] == 'ASC' || $_REQUEST['order'] == 'DESC') {
             $order = $_REQUEST['order'];