function read_author_data($id_author)
{
$q = "SELECT * FROM lcm_author WHERE id_author=" . $id_author;
$result = lcm_query($q);
if (!($usr = lcm_fetch_array($result))) {
lcm_panic("The user #{$id_author} does not exist in the database.");
}
return $usr;
}
function lcm_test_alter_table()
{
$log = "";
lcm_query("DROP TABLE lcm_test", true);
lcm_query("CREATE TABLE lcm_test (a INT)");
lcm_query("ALTER TABLE lcm_test ADD b INT");
lcm_query("INSERT INTO lcm_test (b) VALUES (1)");
$result = lcm_query("SELECT b FROM lcm_test");
lcm_query("ALTER TABLE lcm_test DROP b");
if (!$result) {
$log .= "User does not have the right to modify the database:";
if (lcm_sql_errno()) {
$log .= "<p>" . lcm_sql_error() . "</p>";
} else {
$log .= "<p>" . "No error message available." . "</p>";
}
}
lcm_query("DROP TABLE lcm_test", true);
return $log;
}
$q2 .= ',' . $row['id_client'];
}
$q2 .= ')';
// Add search criteria if any
$find_client_string = _request('find_client_string');
if (strlen($find_client_string) > 1) {
$q2 .= " AND ((name_first LIKE '%{$find_client_string}%')" . " OR (name_middle LIKE '%{$find_client_string}%')" . " OR (name_last LIKE '%{$find_client_string}%'))";
}
$q2 .= ")";
// Sort client by name_first
$order_name = 'ASC';
if (_request('order_name') == 'ASC' || _request('order_name') == 'DESC') {
$order_name = _request('order_name');
}
$q2 .= " ORDER BY name_first " . $order_name;
$result = lcm_query($q2);
lcm_page_start(_T('title_case_add_client'));
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)) {
if ($_REQUEST['sel_time_intervals'] == 'absolute' || $_REQUEST['sel_time_intervals'] == 'relative') {
$prefs['time_intervals'] = $_REQUEST['sel_time_intervals'];
$prefs_mod = true;
}
}
// Set intervals notation
if ($_REQUEST['sel_time_intervals_notation'] != $_REQUEST['old_time_intervals_notation']) {
if (in_array($_REQUEST['sel_time_intervals_notation'], array("hours_only", "floatdays_hours_minutes", "floatdays_floathours_minutes"))) {
$prefs['time_intervals_notation'] = $_REQUEST['sel_time_intervals_notation'];
$prefs_mod = true;
}
}
}
// Update user preferences if modified
if ($prefs_mod) {
lcm_query("UPDATE lcm_author\n\t\t\t\tSET prefs = '" . addslashes(serialize($prefs)) . "'\n\t\t\t\tWHERE id_author = " . $author_session['id_author']);
}
if (isset($lang) and $lang != $lcm_lang) {
// Boomerang via lcm_cookie to set a cookie and do all the dirty work
// The REQUEST_URI should always be set, and point to the current page
// we are being sent to (Ex: from config_author.php to listcases.php).
// [ML] I used $lcm_lang because there are rare cases where the cookie
// can disagree with $author_session['lang'] (e.g. login one user, set
// cookie, logout, login other user, conflict).
// [ML] Added $ref because some forms such as config_author.php expect it
$ref = isset($_REQUEST['referer']) ? '&referer=' . urlencode($_REQUEST['referer']) : '';
header("Location: lcm_cookie.php?var_lang_lcm=" . $lang . "&url=" . urlencode($_SERVER['REQUEST_URI']) . $ref);
exit;
}
//
// Database version management
开发者ID:nyimbi,项目名称:legalcase,代码行数:31,代码来源:inc.php
示例18: save
function save()
{
$errors = $this->validate();
if (count($errors)) {
return $errors;
}
//
// Update
//
$fl = " date_start = '" . $this->getDataString('date_start') . "',\n\t\t\t\tdate_end = '" . $this->getDataString('date_end') . "',\n\t\t\t\ttype = '" . $this->getDataString('type') . "',\n\t\t\t\tsumbilled = " . $this->getDataFloat('sumbilled', 0.0);
if ($this->getDataString('type') == 'stage_change') {
// [ML] To be honest, we should "assert" most of the
// following values, but "new_stage" is the most important.
lcm_assert_value($this->getDataString('new_stage', '__ASSERT__'));
$desc = array('description' => $this->getDataString('description'), 'result' => $this->getDataString('result'), 'conclusion' => $this->getDataString('conclusion'), 'sentence' => $this->getDataString('sentence'), 'sentence_val' => $this->getDataString('sentence_val'), 'new_stage' => $this->getDataString('new_stage'));
$fl .= ", description = '" . serialize($desc) . "'";
} elseif (is_status_change($this->getDataString('type'))) {
$desc = array('description' => $this->getDataString('description'), 'result' => $this->getDataString('result'), 'conclusion' => $this->getDataString('conclusion'), 'sentence' => $this->getDataString('sentence'), 'sentence_val' => $this->getDataString('sentence_val'));
$fl .= ", description = '" . serialize($desc) . "'";
} else {
$fl .= ", description = '" . $this->getDataString('description') . "'";
}
if ($this->getDataInt('id_followup') > 0) {
// Edit of existing follow-up
$id_followup = $this->getDataInt('id_followup');
if (!allowed($this->getDataInt('id_case'), 'e')) {
lcm_panic("You don't have permission to modify this case's information. (" . $this->getDataInt('id_case') . ")");
}
// TODO: check if hiding this FU is allowed
if (allowed($this->getDataInt('id_case'), 'a') && !(is_status_change($this->getDataString('type')) || $this->getDataString('type') == 'assignment' || $this->getDataString('type') == 'unassignment')) {
if ($this->getDataString('delete')) {
$fl .= ", hidden = 'Y'";
} else {
$fl .= ", hidden = 'N'";
}
} else {
$fl .= ", hidden = 'N'";
}
$q = "UPDATE lcm_followup SET {$fl} WHERE id_followup = {$id_followup}";
$result = lcm_query($q);
// Get stage of the follow-up entry
$q = "SELECT id_stage, case_stage FROM lcm_followup WHERE id_followup = {$id_followup}";
$result = lcm_query($q);
if ($row = lcm_fetch_array($result)) {
$case_stage = lcm_assert_value($row['case_stage']);
} else {
lcm_panic("There is no such follow-up (" . $id_followup . ")");
}
// Update the related lcm_stage entry
$q = "UPDATE lcm_stage SET\n\t\t\t\t\tdate_conclusion = '" . $this->getDataString('date_end') . "',\n\t\t\t\t\tkw_result = '" . $this->getDataString('result') . "',\n\t\t\t\t\tkw_conclusion = '" . $this->getDataString('conclusion') . "',\n\t\t\t\t\tkw_sentence = '" . $this->getDataString('sentence') . "',\n\t\t\t\t\tsentence_val = '" . $this->getDataString('sentence_val') . "',\n\t\t\t\t\tdate_agreement = '" . $this->getDataString('date_end') . "'\n\t\t\t\tWHERE id_case = " . $this->getDataInt('id_case') . "\n\t\t\t\t AND kw_case_stage = '" . $case_stage . "'";
lcm_query($q);
} else {
// New follow-up
if (!allowed($this->getDataInt('id_case'), 'w')) {
lcm_panic("You don't have permission to add information to this case. (" . $this->getDataInt('id_case') . ")");
}
// Get the current case stage
$q = "SELECT id_stage, stage FROM lcm_case WHERE id_case=" . $this->getDataInt('id_case', '__ASSERT__');
$result = lcm_query($q);
if ($row = lcm_fetch_array($result)) {
$case_stage = lcm_assert_value($row['stage']);
$case_stage_id = lcm_assert_value($row['id_stage']);
} else {
lcm_panic("There is no such case (" . $this->getDataInt('id_case') . ")");
}
// Add the new follow-up
$q = "INSERT INTO lcm_followup\n\t\t\t\t\tSET id_case=" . $this->getDataInt('id_case') . ",\n\t\t\t\t\t\tid_author=" . $GLOBALS['author_session']['id_author'] . ",\n\t\t\t\t\t\t{$fl},\n\t\t\t\t\t\tid_stage = {$case_stage_id},\n\t\t\t\t\t\tcase_stage='{$case_stage}'";
lcm_query($q);
$this->data['id_followup'] = lcm_insert_id('lcm_followup', 'id_followup');
// Set relation to the parent appointment, if any
if ($this->getDataInt('id_app')) {
$q = "INSERT INTO lcm_app_fu \n\t\t\t\t\t\tSET id_app=" . $this->getDataInt('id_app') . ",\n\t\t\t\t\t\t\tid_followup=" . $this->getDataInt('id_followup', '__ASSERT__') . ",\n\t\t\t\t\t\t\trelation='child'";
$result = lcm_query($q);
}
// Update case status
$status = '';
$stage = '';
switch ($this->getDataString('type')) {
case 'conclusion':
$status = 'closed';
break;
case 'suspension':
$status = 'suspended';
break;
case 'opening':
case 'resumption':
case 'reopening':
$status = 'open';
break;
case 'merge':
$status = 'merged';
break;
case 'deletion':
$status = 'deleted';
break;
case 'stage_change':
$stage = lcm_assert_value($this->getDataString('new_stage'));
break;
}
if ($status || $stage) {
//.........这里部分代码省略.........
请发表评论