Ejemplo n.º 1
0
function get_unique_username($username)
{
    $username = strtolower($username);
    $username = ereg_replace("[^a-zA-Z0-9]", "", $username);
    if (!$username) {
        $username = "******";
    }
    $unique_name = $username;
    for ($i = 0;; $i++) {
        if ($i) {
            $unique_name = $username . $i;
        } else {
            $unique_name = $username;
        }
        $query = "SELECT id_author FROM lcm_author WHERE username='******'";
        $result = lcm_query($query);
        if (!lcm_num_rows($result)) {
            break;
        }
    }
    return $unique_name;
}
Ejemplo n.º 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";
     }
 }
Ejemplo n.º 3
0
 function loadCases($list_pos = 0)
 {
     global $prefs;
     $q = "SELECT clo.id_case, c.*\n\t\t\t\tFROM lcm_case_client_org as clo, lcm_case as c\n\t\t\t\tWHERE clo.id_client = " . $this->getDataInt('id_client', '__ASSERT__') . "\n\t\t\t\tAND clo.id_case = c.id_case ";
     // Sort cases by creation date
     $case_order = 'DESC';
     if (_request('case_order') == 'ASC' || _request('case_order') == 'DESC') {
         $case_order = _request('case_order');
     }
     $q .= " ORDER BY c.date_creation " . $case_order;
     $result = lcm_query($q);
     $number_of_rows = lcm_num_rows($result);
     if ($list_pos >= $number_of_rows) {
         return;
     }
     // 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)) {
         for ($cpt = 0; $cpt < $prefs['page_rows'] && ($row = lcm_fetch_array($result)); $cpt++) {
             array_push($this->cases, $row);
         }
     }
 }
Ejemplo n.º 4
0
function is_existing_contact($type_person, $id = 0, $type_contact, $value)
{
    // XXX FIXME TODO very temporary untill we solved this issue..
    if ($type_contact == 'email') {
        //		$type_contact = 1;
        //		[AG] I assume that 'email' means any e-mail contact type
        //		If not, $type_contact should be set here to what 'email' means
        $type_contact = array('email_main', 'email_alternate');
    }
    //	else
    //		echo "Wrong get_contact_author type ($type_contact)";
    $id = intval($id);
    //	$type_contact = intval($type_contact);
    $value = clean_input($value);
    $query = "SELECT id_contact\n\t\t\t\tFROM lcm_contact\n\t\t\t\tWHERE ((value = '{$value}')";
    if ($type_person) {
        $query .= " AND (type_person = '{$type_person}')";
    }
    if ($id) {
        $query .= " AND (id_of_person = {$id})";
    }
    if ($type_contact) {
        // [AG] Let's try this - we accept for $type_contact integer, string or array of integers or strings
        // Thus we can specify more flexible searches
        switch (gettype($type_contact)) {
            case "string":
                if ($type_contact[0] != '+') {
                    $type_contact = '+' . $type_contact;
                }
                $type_contact = get_contact_type_id($type_contact);
            case "integer":
                $query .= " AND (type_contact = {$type_contact})";
                break;
            case "array":
                $qs = '';
                foreach ($type_contact as $tc) {
                    if (gettype($tc) == 'string') {
                        if ($tc[0] != '+') {
                            $tc = '+' . $tc;
                        }
                        $tc = get_contact_type_id($tc);
                    }
                    $tc = intval($tc);
                    $qs .= ($qs ? ',' : '') . $tc;
                }
                $query .= " AND (type_contact IN ({$qs})";
                break;
            default:
                lcm_panic("Wrong is_existing_contact type_contact ({$type_contact})");
        }
    }
    $query .= ")";
    $result = lcm_query($query);
    return lcm_num_rows($result) > 0;
}
Ejemplo n.º 5
0
}
if ($row['id_case'] > 0) {
    // Show parent followup ([ML] fu.type necessary for short-desc)
    $q = "SELECT a.id_followup, fu.description, fu.type\n\t\t\t\tFROM lcm_app_fu as a, lcm_followup as fu\n\t\t\t\tWHERE a.id_app = " . $row['id_app'] . "\n\t\t\t  \t  AND a.id_followup = fu.id_followup\n\t\t\t\t  AND a.relation = 'parent'";
    $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
Ejemplo n.º 6
0
function show_report_field_edit($type, $rep_info)
{
    $src_type = $rep_info[$type . '_src_type'];
    $src_name = $rep_info[$type . '_src_name'];
    if ($src_type == 'table' && $src_name && !preg_match('/^lcm_/', $src_name)) {
        $src_name = 'lcm_' . $src_name;
    }
    // Extract source type, if any
    if ($src_type && $src_name) {
        if ($src_type == 'keyword') {
            $kwg = get_kwg_from_name($src_name);
            echo '<p class="normal_text">' . _Ti('rep_info_source_' . $src_type) . " (" . _T('rep_info_table_lcm_' . $kwg['type']) . ") " . _T(remove_number_prefix($kwg['title']));
        } else {
            echo "<p class='normal_text'>" . _Ti('rep_info_source_' . $src_type) . _T('rep_info_table_' . $src_name);
        }
        // Show list of fields for line/col, if any
        $my_id = $type == 'col' ? 'id_column' : 'id_line';
        $my_fields = array();
        $query = "SELECT " . $my_id . ", f.id_field, f.description \n\t\t\tFROM lcm_rep_" . $type . " as rl, lcm_fields as f\n\t\t\tWHERE id_report = " . $rep_info['id_report'] . "\n\t\t\tAND rl.id_field = f.id_field\n\t\t\tORDER BY col_order, " . $my_id . " ASC";
        $result_fields = lcm_query($query);
        if (lcm_num_rows($result_fields)) {
            echo "</p>\n";
            echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
            while ($field = lcm_fetch_array($result_fields)) {
                echo "<tr>\n";
                echo "<td>" . _Th($field['description']) . "</td>\n";
                echo "<td><a href='upd_rep_field.php?rep=" . $rep_info['id_report'] . "&amp;" . "remove=" . $type . "&amp;" . $my_id . "=" . $field[$my_id] . "' class='content_link'>" . "X" . "</a></td>\n";
                // ACCESSIBILITY
                echo "</tr>\n";
                array_push($my_fields, $field['id_field']);
            }
            echo "</table>\n";
        } else {
            if (!$rep_info['filecustom']) {
                // Allow to change the source table
                echo ' <a href="upd_rep_field.php?rep=' . $rep_info['id_report'] . '&amp;unselect_' . $type . '=1" class="content_link">' . "X" . '</a>';
                // TRAD ACCESSIBILITY
                echo "</p>\n";
            }
        }
        // Add field (if line_src_type == table)
        // TODO: add 'not in (...existing fields..)
        $query = "SELECT *\n\t\t\tFROM lcm_fields\n\t\t\tWHERE table_name = '" . $src_name . "'";
        $result = lcm_query($query);
        if (lcm_num_rows($result)) {
            echo "\n<br />\n\n";
            echo "<form action='upd_rep_field.php' name='frm_" . $type . "_additem' method='get'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo "<input name='add' value='" . $type . "' type='hidden' />\n";
            echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
            echo "<tr>\n";
            echo "<th class='heading'>" . _Ti('rep_input_item_add') . "</th>\n";
            echo "<td>\n";
            echo "<select name='id_field' class='sel_frm'>";
            echo "<option value=''>...</option>\n";
            while ($row = lcm_fetch_array($result)) {
                echo "<option value='" . $row['id_field'] . "'>" . _Th($row['description']) . "</option>\n";
            }
            echo "</select>\n";
            echo "<button class='simple_form_btn' name='validate_" . $type . "_additem'>" . _T('button_validate') . "</button>\n";
            echo "</td>\n";
            echo "</tr>\n";
            echo "</table>\n";
            echo "</form>\n";
        }
    } else {
        if (!$src_type || $src_type != 'keyword') {
            echo "<form action='upd_rep_field.php' name='frm_" . $type . "_source' method='post'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo '<p class="normal_text">' . f_err_star('rep_' . $type) . _Ti('rep_info_source_table');
            echo "<input name='select_" . $type . "_type' value='table' type='hidden' />\n";
            echo "<select name='select_" . $type . "_name' class='sel_frm'>\n\t\t\t\t<option value='author'>" . _T('rep_info_table_lcm_author') . "</option>\n\t\t\t\t<option value='case'>" . _T('rep_info_table_lcm_case') . "</option>\n\t\t\t\t<option value='stage'>" . _T('rep_info_table_lcm_stage') . "</option>\n\t\t\t\t<option value='client'>" . _T('rep_info_table_lcm_client') . "</option>\n\t\t\t\t<option value='followup'>" . _T('rep_info_table_lcm_followup') . "</option>\n\t\t\t\t</select>\n";
            echo "<button class='simple_form_btn' name='validate_" . $type . "_source'>" . _T('button_validate') . "</button>\n";
            echo "</p>\n";
            echo "</form>\n";
        }
        if (!$src_type) {
            echo '<p class="normal_text">' . _T('info_or') . "</p>\n";
        }
        if (!$src_type || $src_type != 'table') {
            echo "<form action='upd_rep_field.php' name='frm_" . $type . "_source' method='post'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo "<p class='normal_text'>" . _Ti('rep_info_source_keyword');
            echo "<input name='select_" . $type . "_type' value='keyword' type='hidden' />\n";
            // Restrict list of keywords if custom report
            if ($rep_info['filecustom']) {
                include_custom_report($rep_info['filecustom']);
                $obj = new CustomReportSpecs();
                $info = $type == 'line' ? $obj->getReportLine() : $obj->getReportCol();
                if (substr($info['name'], 0, 4) == 'FOR:') {
                    $choices = split(':', $info['name']);
                    $all_kwgs = get_kwg_all($choices[1], true);
                } else {
                    lcm_panic("Error in custom report specifications.");
                }
            } else {
                $all_kwgs = get_kwg_all('', true);
            }
            echo "<select name='select_" . $type . "_name' class='sel_frm'>\n";
            echo "<option value=''>...</option>\n";
            foreach ($all_kwgs as $kwg) {
                echo "<option value='" . $kwg['name'] . "'>" . _T('rep_info_table_lcm_' . $kwg['type']) . " - " . _T(remove_number_prefix($kwg['title'])) . "</option>\n";
            }
            echo "</select>\n";
            echo "<button class='simple_form_btn' name='validate_" . $type . "_source_kw'>" . _T('button_validate') . "</button>\n";
            echo "</p>\n";
            echo "</form>\n";
        }
    }
}
Ejemplo n.º 7
0
function export($type, $format, $search = '')
{
    switch ($type) {
        case 'case':
            // List cases in the system + search criterion if any
            $q = "SELECT id_case,title,legal_reason,alledged_crime,notes,status,stage\n\t\t\t\t\tFROM lcm_case";
            if (strlen($search) > 1) {
                // Add search criteria
                $q .= " WHERE ((title LIKE '%{$search}%')\n\t\t\t\t\t\tOR (status LIKE '%{$search}%')\n\t\t\t\t\t\tOR (stage LIKE '%{$search}%'))";
            }
            break;
        case 'client':
            // List clients in the system + search criterion if any
            $q = "SELECT id_client,name_first,name_middle,name_last,citizen_number,civil_status,income,gender,notes\n\t\t\t\t\tFROM lcm_client";
            if (strlen($search) > 1) {
                // Add search criteria
                $q .= " WHERE ((name_first LIKE '%{$search}%')\n\t\t\t\t\t\tOR (name_middle LIKE '%{$search}%')\n\t\t\t\t\t\tOR (name_last LIKE '%{$search}%'))";
            }
            break;
        case 'org':
            // List organizations in the system + search criterion if any
            $q = "SELECT id_org,name,notes,court_reg,tax_number,stat_number\n\t\t\t\t\tFROM lcm_org";
            if (strlen($search) > 1) {
                // Add search criteria
                $q .= " WHERE (name LIKE '%{$search}%')";
            }
            break;
        default:
            lcm_panic("invalid type: {$type}");
            return 0;
    }
    $mime_types = array('csv' => 'text/comma-separated-values', 'xml' => 'text/xml');
    if (!($mime_type = $mime_types[$format])) {
        lcm_panic("invalid type: {$type}");
        return 0;
    }
    $result = lcm_query($q);
    if (lcm_num_rows($result) > 0) {
        // Send proper headers to browser
        header("Content-Type: " . $mime_type);
        header("Content-Disposition: filename={$type}.{$format}");
        header("Content-Description: " . "Export of {$type}s");
        header("Content-Transfer-Encoding: binary");
        //		echo ( get_magic_quotes_runtime() ? stripslashes($row['content']) : $row['content'] );
        // Document start
        switch ($format) {
            case 'csv':
                // Export columns headers
                break;
            case 'xml':
                echo "<document>\r\n";
                break;
        }
        // Document contents
        while ($row = lcm_fetch_assoc($result)) {
            // Export row start
            switch ($format) {
                case 'csv':
                    break;
                case 'xml':
                    echo "\t<row>\r\n";
                    break;
            }
            // Prepare row fields
            $fields = array();
            foreach ($row as $key => $value) {
                // Remove escaping if any
                $value = get_magic_quotes_runtime() ? stripslashes($value) : $value;
                switch ($format) {
                    case 'csv':
                        if (is_string($value)) {
                            // Escape double quote in CVS style
                            $value = str_replace('"', '""', $value);
                            // Add double quotes
                            $value = "\"{$value}\"";
                        }
                        break;
                    case 'xml':
                        $value = is_string($value) ? htmlspecialchars($value) : $value;
                        $value = "\t\t<{$key}>{$value}</{$key}>\r\n";
                        break;
                }
                $fields[] = $value;
            }
            // Export row end
            switch ($format) {
                case 'csv':
                    echo join(',', $fields) . "\r\n";
                    break;
                case 'xml':
                    echo join('', $fields);
                    echo "\t</row>\r\n";
                    break;
            }
        }
        // Document end
        switch ($format) {
            case 'csv':
                break;
            case 'xml':
                echo "</document>\r\n";
                break;
        }
    }
}
Ejemplo n.º 8
0
}
$q .= ")";
// Sort organisations by name
$order_name = 'ASC';
if (_request('order_name') == 'ASC' || _request('order_name') == 'DESC') {
    $order_name = _request('order_name');
}
$q .= " ORDER BY name " . $order_name;
$result = lcm_query($q);
lcm_page_start(_T('title_case_add_org'));
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)) {
        die("Error seeking position {$list_pos} in the result");
    }
}
show_find_box('org', $find_org_string, '__self__');
echo '<form action="add_client.php" method="post">' . "\n";
$headers[0]['title'] = "";
$headers[0]['order'] = 'no_order';
Ejemplo n.º 9
0
function check_if_kwg_name_unique($name)
{
    $query = "SELECT id_group\n\t\t\t\tFROM lcm_keyword_group\n\t\t\t\tWHERE name = '" . clean_input($name) . "'";
    $result = lcm_query($query);
    return lcm_num_rows($result) == 0;
}
Ejemplo n.º 10
0
 function activate()
 {
     $nom = addslashes($this->nom);
     $login = addslashes($this->login);
     $email = addslashes($this->email);
     $bio = addslashes($this->bio);
     $statut = read_meta("ldap_statut_import");
     if (!$statut) {
         return false;
     }
     // If the author does not exist, insert with the default status (defined at installation)
     // [ML] lcm-ification not tested XXX
     $query = "SELECT id_author FROM lcm_author WHERE username='******'";
     $result = lcm_query($query);
     if (lcm_num_rows($result)) {
         return false;
     }
     // XXX
     $query = "INSERT IGNORE INTO lcm_author (source, name, username, email, bio, status, pass) " . "VALUES ('ldap', '{$nom}', '{$login}', '{$email}', '{$bio}', '{$statut}', '')";
     return lcm_query($query);
 }
Ejemplo n.º 11
0
function spip_num_rows($r)
{
    lcm_log("use of deprecated function: spip_num_rows, use lcm_num_rows instead");
    return lcm_num_rows($r);
}
Ejemplo n.º 12
0
    //
    case 'client':
        $q = "SELECT *\n\t\t\tFROM lcm_client_attachment\n\t\t\tWHERE id_attachment={$file_id}";
        $result = lcm_query($q);
        if (lcm_num_rows($result) == 0) {
            die("There is no such file!");
        }
        $row = lcm_fetch_array($result);
        break;
        //
        // View organisation attachment
        //
    //
    // View organisation attachment
    //
    case 'org':
        $q = "SELECT *\n\t\t\tFROM lcm_org_attachment\n\t\t\tWHERE id_attachment={$file_id}";
        $result = lcm_query($q);
        if (lcm_num_rows($result) == 0) {
            die("There is no such file!");
        }
        $row = lcm_fetch_array($result);
        break;
    default:
        die("What type of attachment?");
}
header("Content-Type: " . ($row['type'] ? $row['type'] : "application/octet-stream"));
header("Content-Disposition: filename=" . $row['filename']);
header("Content-Description: " . $row['description']);
header("Content-Transfer-Encoding: binary");
echo get_magic_quotes_runtime() ? stripslashes($row['content']) : $row['content'];
Ejemplo n.º 13
0
 $result = lcm_query($q);
 $number_of_rows = lcm_num_rows($result);
 $list_pos = 0;
 if (isset($_REQUEST['list_pos'])) {
     $list_pos = $_REQUEST['list_pos'];
 }
 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
 //
Ejemplo n.º 14
0
function install_step_3()
{
    $db_address = _request('db_address');
    $db_login = _request('db_login');
    $db_password = _request('db_password');
    global $lcm_db_version;
    $install_log = "";
    $upgrade_log = "";
    // Possible errors will get trapped in the output buffer and displayed later,
    // so that they don't mess up with headers/html.
    ob_start();
    if (_request('db_choice') == "__manual__") {
        $sel_db = _request('manual_db');
    } else {
        $sel_db = _request('db_choice');
    }
    $link = lcm_connect_db($db_address, 0, $db_login, $db_password, $sel_db);
    $io_output = ob_get_contents();
    ob_end_clean();
    if (!$link) {
        install_html_start('AUTO', '', 3);
        lcm_panic("connection denied: " . lcm_sql_error());
    }
    //
    // TEMPORARY (used by testing the installer)
    /*
    lcm_query("DROP TABLE lcm_case", true);
    lcm_query("DROP TABLE lcm_case_attachment", true);
    lcm_query("DROP TABLE lcm_stage", true);
    lcm_query("DROP TABLE lcm_followup", true);
    lcm_query("DROP TABLE lcm_author", true);
    lcm_query("DROP TABLE lcm_client", true);
    lcm_query("DROP TABLE lcm_client_attachment", true);
    lcm_query("DROP TABLE lcm_org", true);
    lcm_query("DROP TABLE lcm_org_attachment", true);
    lcm_query("DROP TABLE lcm_contact", true);
    lcm_query("DROP TABLE lcm_keyword", true);
    lcm_query("DROP TABLE lcm_keyword_case", true);
    lcm_query("DROP TABLE lcm_keyword_client", true);
    lcm_query("DROP TABLE lcm_keyword_org", true);
    lcm_query("DROP TABLE lcm_keyword_group", true);
    lcm_query("DROP TABLE lcm_report", true);
    lcm_query("DROP TABLE lcm_fields", true);
    lcm_query("DROP TABLE lcm_filter", true);
    lcm_query("DROP TABLE lcm_app", true);
    lcm_query("DROP TABLE lcm_app_client_org", true);
    lcm_query("DROP TABLE lcm_app_fu", true);
    lcm_query("DROP TABLE lcm_author_app", true);
    lcm_query("DROP TABLE lcm_case_client_org", true);
    lcm_query("DROP TABLE lcm_case_author", true);
    lcm_query("DROP TABLE lcm_client_org", true);
    lcm_query("DROP TABLE lcm_rep_col", true);
    lcm_query("DROP TABLE lcm_rep_line", true);
    lcm_query("DROP TABLE lcm_rep_filters", true);
    lcm_query("DROP TABLE lcm_filter_conds", true);
    lcm_query("DROP TABLE lcm_rep_filter", true);
    lcm_query("DROP TABLE lcm_meta", true);
    */
    // Test if the software was already installed
    $result = lcm_query("SELECT * FROM lcm_meta", true);
    $already_installed = !lcm_sql_errno() && lcm_num_rows($result);
    $old_lcm_version = 'NONE';
    if ($already_installed) {
        lcm_log("LCM already installed", 'install');
        // Find the current database version
        $old_lcm_db_version = 0;
        $query = "SELECT value FROM lcm_meta WHERE name = 'lcm_db_version'";
        $result = lcm_query_db($query);
        while ($row = lcm_fetch_array($result)) {
            $old_lcm_db_version = $row['value'];
        }
        lcm_log("LCM version installed is {$old_lcm_db_version}", 'install');
        // Check if upgrade is needed
        if ($old_lcm_db_version < $lcm_db_version) {
            lcm_log("Calling the upgrade procedure (since < {$lcm_db_version})", 'install');
            include_lcm('inc_db_upgrade');
            $upgrade_log = upgrade_database($old_lcm_db_version);
        } else {
            lcm_log("Upgrade _not_ called, looks OK (= {$lcm_db_version})", 'install');
        }
    } else {
        lcm_log("Creating the database from scratch", 'install');
        include_lcm('inc_db_create');
        $install_log .= create_database();
        lcm_log("DB creation complete", 'install');
    }
    // Create default meta + keywords
    include_lcm('inc_meta');
    include_lcm('inc_keywords_default');
    include_lcm('inc_meta_defaults');
    init_default_config();
    init_languages();
    $skwg = get_default_keywords();
    create_groups($skwg);
    write_metas();
    // regenerate inc/data/inc_meta_cache.php
    // Test DB: not used for now..
    include_lcm('inc_db_test');
    $structure_ok = lcm_structure_test();
    if (!empty($install_log)) {
        install_html_start('AUTO', '', 3);
        echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
        echo "<div class='box_error'>\n";
        echo "<p>";
        echo "<b>" . _T('warning_operation_failed') . "</b> " . _T('install_database_install_failed');
        echo " " . lcm_help("install_connection") . "</p>\n";
        echo "</div>\n";
        // Dump error listing
        echo put_text_in_textbox($install_log);
        install_html_end();
    } else {
        if (!empty($upgrade_log)) {
            install_html_start('AUTO', '', 3);
            echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
            echo "<div class='box_error'>\n";
            echo "<p>" . _T('install_warning_update_impossible', array('old_version' => $old_lcm_version, 'version' => $lcm_version)) . "</p>\n";
            echo "</div>\n";
            // Dump error listing
            echo put_text_in_textbox($upgrade_log);
            install_html_end();
        } else {
            if (!$structure_ok) {
                install_html_start('AUTO', '', 3);
                echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
                echo "<div class='box_error'>\n";
                echo "<p> STRUCTURE PROBLEM </p>\n";
                // TRAD
                echo "</div>\n";
                install_html_end();
            } else {
                // Everything OK
                $conn = '<' . '?php' . "\n";
                $conn .= "if (defined('_CONFIG_INC_CONNECT')) return;\n";
                $conn .= "define('_CONFIG_INC_CONNECT', '1');\n";
                $conn .= "\$GLOBALS['lcm_connect_version'] = 0.1;\n";
                $conn .= "include_lcm('inc_db');\n";
                $conn .= "@lcm_connect_db('{$db_address}','','{$db_login}','{$db_password}','{$sel_db}');\n";
                $conn .= "\$GLOBALS['db_ok'] = !!@lcm_num_rows(@lcm_query_db('SELECT COUNT(*) FROM lcm_meta'));\n";
                $conn .= '?' . '>';
                $lcm_config_prefix = isset($_SERVER['LcmConfigDir']) ? $_SERVER['LcmConfigDir'] : 'inc/config';
                $myFile = fopen($lcm_config_prefix . '/inc_connect_install.php', 'wb');
                fputs($myFile, $conn);
                fclose($myFile);
                install_step_4();
            }
        }
    }
}
Ejemplo n.º 15
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);
     }
 }
Ejemplo n.º 16
0
function show_report_filters($id_report, $is_runtime = false)
{
    // Get general report info
    $q = "SELECT * FROM lcm_report WHERE id_report = " . intval($id_report);
    $res = lcm_query($q);
    $rep_info = lcm_fetch_array($res);
    if (!$rep_info) {
        lcm_panic("Report does not exist: {$id_report}");
    }
    // List filters attached to this report
    $query = "SELECT *\n\t\tFROM lcm_rep_filter as v, lcm_fields as f\n\t\tWHERE id_report = " . $id_report . "\n\t\tAND f.id_field = v.id_field";
    // If generating the report (as opposed to editing), show filters
    // who have a filter type (eq, neq, in, ..), but no value.
    if ($is_runtime) {
        $query .= " AND v.type != '' AND v.value = '' ";
    }
    $result = lcm_query($query);
    if (lcm_num_rows($result)) {
        if ($is_runtime) {
            // submit all at once (else submit on a per-filter basis)
            echo '<form action="run_rep.php" name="frm_filters" method="get">' . "\n";
            echo '<input name="rep" value="' . $id_report . '" type="hidden" />' . "\n";
            if (isset($_REQUEST['export'])) {
                echo '<input name="export" value="' . $_REQUEST['export'] . '" type="hidden" />' . "\n";
            }
        }
        echo "<table border='0' class='tbl_usr_dtl' width='99%'>\n";
        while ($filter = lcm_fetch_array($result)) {
            if (!$is_runtime) {
                echo "<form action='upd_rep_field.php' name='frm_line_additem' method='get'>\n";
                echo "<input name='update' value='filter' type='hidden' />\n";
                echo "<input name='rep' value='{$id_report}' type='hidden' />\n";
                echo "<input name='id_filter' value='" . $filter['id_filter'] . "' type='hidden' />\n";
            }
            echo "<tr>\n";
            echo "<td>" . _Th($filter['description']) . "</td>\n";
            // Type of filter
            echo "<td>";
            $all_filters = array('number' => array('none', 'num_eq', 'num_neq', 'num_lt', 'num_le', 'num_gt', 'num_ge'), 'date' => array('none', 'date_eq', 'date_in', 'date_lt', 'date_le', 'date_gt', 'date_ge'), 'text' => array('none', 'text_eq', 'text_neq'));
            if ($all_filters[$filter['filter']]) {
                // At runtime, if a filter has been selected, do not allow select
                if ($filter['type'] && $is_runtime) {
                    echo _T('rep_filter_' . $filter['type']);
                } else {
                    echo "<select name='filter_type'>\n";
                    echo "<option value=''>...</option>\n";
                    foreach ($all_filters[$filter['filter']] as $f) {
                        $sel = $filter['type'] == $f ? ' selected="selected"' : '';
                        echo "<option value='" . $f . "'" . $sel . ">" . _T('rep_filter_' . $f) . "</option>\n";
                    }
                    echo "</select>\n";
                }
            } else {
                // XXX Should happen only if a filter was removed in a future version, e.g. rarely
                // or between development releases.
                echo "Unknown filter";
            }
            echo "</td>\n";
            // Value for filter
            echo "<td>";
            switch ($filter['type']) {
                case 'num_eq':
                case 'num_neq':
                    if ($filter['field_name'] == 'id_author') {
                        $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
                        // XXX make this a function
                        $q = "SELECT * FROM lcm_author WHERE status IN ('admin', 'normal', 'external')";
                        $result_author = lcm_query($q);
                        echo "<select name='{$name}'>\n";
                        echo "<option value=''>...</option>\n";
                        // TRAD
                        while ($author = lcm_fetch_array($result_author)) {
                            // Check for already submitted value
                            $sel = $filter['value'] == $author['id_author'] || $_REQUEST['filter_val' . $filter['id_filter']] == $author['id_author'] ? ' selected="selected"' : '';
                            echo "<option value='" . $author['id_author'] . "'" . $sel . ">" . $author['id_author'] . " : " . get_person_name($author) . "</option>\n";
                        }
                        echo "</select>\n";
                        break;
                    }
                case 'num_lt':
                case 'num_gt':
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
                    echo '<input style="width: 99%;" type="text" name="' . $name . '" value="' . $filter['value'] . '" />';
                    break;
                case 'date_eq':
                case 'date_lt':
                case 'date_le':
                case 'date_gt':
                case 'date_ge':
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'date';
                    echo get_date_inputs($name, $filter['value']);
                    // FIXME
                    break;
                case 'date_in':
                    // date_in has two values, stored ex: 2005-01-01 00:00:00;2006-02-02 00:00:00
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'date';
                    $values = split(";", $filter['value']);
                    echo get_date_inputs($name . '_start', $values[0]);
                    echo "<br />\n";
                    echo get_date_inputs($name . '_end', $values[1]);
                    break;
                case 'text_eq':
                case 'text_neq':
                    $name = $is_runtime ? "filter_val" . $filter['id_filter'] : 'filter_value';
                    if ($filter['enum_type']) {
                        $enum = explode(":", $filter['enum_type']);
                        if ($enum[0] == 'keyword') {
                            if ($enum[1] == 'system_kwg') {
                                $all_kw = get_keywords_in_group_name($enum[2]);
                                echo '<select name="' . $name . '">' . "\n";
                                echo '<option value="">' . "..." . "</option>\n";
                                // TRAD
                                foreach ($all_kw as $kw) {
                                    $sel = $filter['value'] == $kw['name'] || $_REQUEST['filter_val' . $filter['id_filter']] == $kw['name'] ? ' selected="selected" ' : '';
                                    echo '<option value="' . $kw['name'] . '"' . $sel . '>' . _Tkw($enum[2], $kw['name']) . "</option>\n";
                                }
                                echo "</select>\n";
                            }
                        } elseif ($enum[0] == 'list') {
                            $items = split(",", $enum[1]);
                            echo '<select name="' . $name . '">' . "\n";
                            echo '<option value="">' . "..." . "</option>\n";
                            // TRAD
                            foreach ($items as $i) {
                                $tmp = $i;
                                if ($enum[2]) {
                                    $tmp = _T($enum[2] . $tmp);
                                }
                                $sel = $filter['value'] == $i || $_REQUEST['filter_val' . $filter['id_filter']] == $i ? ' selected="selected" ' : '';
                                echo '<option value="' . $i . '"' . $sel . '>' . $tmp . "</option>\n";
                            }
                            echo "</select>\n";
                        }
                    } else {
                        echo '<input style="width: 99%;" type="text" name="' . $name . '" value="' . $filter['value'] . '" />';
                    }
                    break;
                default:
                    echo "<!-- no type -->\n";
            }
            echo "</td>\n";
            if (!$is_runtime) {
                // Button to validate
                echo "<td>";
                echo "<button class='simple_form_btn' name='validate_filter_addfield'>" . _T('button_validate') . "</button>\n";
                echo "</td>\n";
                // Link for "Remove"
                echo "<td><a class='content_link' href='upd_rep_field.php?rep=" . $id_report . "&amp;" . "remove=filter" . "&amp;" . "id_filter=" . $filter['id_filter'] . "'>" . "X" . "</a></td>\n";
            }
            echo "</tr>\n";
            if (!$is_runtime) {
                echo "</form>\n";
            }
        }
        echo "</table>\n";
    }
    if ($is_runtime) {
        echo "<p><button class='simple_form_btn' name='validate_filter_addfield'>" . _T('button_validate') . "</button></p>\n";
        echo "</form>\n";
        return;
    }
    // List all available fields in selected tables for report
    $query = "SELECT *\n\t\tFROM lcm_fields\n\t\tWHERE ";
    $sources = array();
    if ($rep_info['line_src_name']) {
        array_push($sources, "'lcm_" . $rep_info['line_src_name'] . "'");
    }
    // Fetch all tables available as rep colums
    // (this is not like rep line, because the source is not always in
    // lcm_report, but this should be 'fixed')
    $q_tmp = "SELECT DISTINCT table_name \n\t\t\t\tFROM lcm_rep_col as rp, lcm_fields as f\n\t\t\t\tWHERE rp.id_field = f.id_field\n\t\t\t\t  AND rp.id_report = " . $id_report;
    $result_tmp = lcm_query($q_tmp);
    while ($row = lcm_fetch_array($result_tmp)) {
        array_push($sources, "'" . $row['table_name'] . "'");
    }
    // Fetch all keyword sources
    if ($rep_info['col_src_type'] == 'keyword' && $rep_info['col_src_name']) {
        $kwg = get_kwg_from_name($rep_info['col_src_name']);
        if ($kwg['type'] == 'system') {
            switch ($kwg['name']) {
            }
        } else {
            if ($kwg['type'] == 'client_org') {
                array_push($sources, "'lcm_client'");
                array_push($sources, "'lcm_org'");
            } else {
                array_push($sources, "'lcm_" . $kwg['type'] . "'");
            }
        }
    }
    // If lcm_case in there, also add lcm_stage
    $tmp = '';
    foreach ($sources as $s) {
        if ($s == "'lcm_case'") {
            $tmp = "lcm_stage";
        }
    }
    if ($tmp) {
        array_push($sources, "'lcm_stage'");
    }
    // List only filters if table were selected as sources (line/col)
    if (count($sources)) {
        $query .= " table_name IN ( " . implode(" , ", $sources) . " ) AND ";
        $query .= " filter != 'none'";
        $query .= " ORDER BY table_name ";
        echo "<!-- QUERY: {$query} -->\n";
        $result = lcm_query($query);
        if (lcm_num_rows($result)) {
            echo "<form action='upd_rep_field.php' name='frm_line_additem' method='get'>\n";
            echo "<input name='rep' value='" . $rep_info['id_report'] . "' type='hidden' />\n";
            echo "<input name='add' value='filter' type='hidden' />\n";
            echo "<p class='normal_text'>" . _Ti('rep_input_filter_add');
            echo "<select name='id_field'>\n";
            echo "<option value=''>...</option>\n";
            while ($row = lcm_fetch_array($result)) {
                echo "<option value='" . $row['id_field'] . "'>" . _Ti('rep_info_table_' . $row['table_name']) . _Th($row['description']) . "</option>\n";
            }
            echo "</select>\n";
            echo "<button class='simple_form_btn' name='validate_filter_addfield'>" . _T('button_validate') . "</button>\n";
            echo "</p>\n";
            echo "</form>\n";
        }
    } else {
        echo '<p class="normal_text">' . _T('rep_info_select_source_first') . "</p>\n";
    }
}
Ejemplo n.º 17
0
// Check for correct start position of the list
$list_pos = 0;
if (isset($_REQUEST['list_pos'])) {
    $list_pos = $_REQUEST['list_pos'];
}
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");
    }
}
// Check if any author(s) available for selection
if ($find_author_string || lcm_num_rows($result) > 0) {
    lcm_page_start(_T('title_case_add_author'), '', '', 'cases_participants');
} else {
    // TODO: add $_SESSION['errors']['generic'] message?
    header('Location: ' . $dest_link->getUrlForHeader());
    exit;
}
show_context_start();
show_context_case_title($case);
show_context_case_involving($case);
show_context_end();
show_find_box('author', $find_author_string, '__self__');
echo '<form action="add_auth.php" method="post">' . "\n";
$headers = array();
$headers[0]['title'] = '';
$headers[0]['order'] = 'no_order';
Ejemplo n.º 18
0
        if (!($row = lcm_fetch_array($result))) {
            lcm_panic("There's no such appointment (app = {$app})");
        }
        // Get participant author(s)
        $participants = array();
        $q = "SELECT lcm_author_app.*,lcm_author.name_first,lcm_author.name_middle,lcm_author.name_last\n\t\t\t\t\tFROM lcm_author_app, lcm_author\n\t\t\t\t\tWHERE (id_app={$app} AND lcm_author_app.id_author=lcm_author.id_author)";
        $res_author = lcm_query($q);
        if (lcm_num_rows($res_author) > 0) {
            while ($author = lcm_fetch_array($res_author)) {
                $participants[] = get_person_name($author);
            }
        }
        // Get appointment client(s)
        $q = "SELECT aco.*, c.name_first, c.name_middle, c.name_last, o.name\n\t\t\t\t\tFROM lcm_app_client_org as aco\n\t\t\t\t\tNATURAL JOIN lcm_client as c\n\t\t\t\t\tLEFT JOIN lcm_org as o ON (o.id_org = aco.id_org)\n\t\t\t\t\tWHERE (id_app = {$app} AND aco.id_client = c.id_client)";
        $res_client = lcm_query($q);
        if (lcm_num_rows($res_client) > 0) {
            while ($client = lcm_fetch_array($res_client)) {
                $participants[] = get_person_name($client) . ($client['id_org'] > 0 ? " of " . $client['name'] : '');
            }
            // TRAD
        }
        $_SESSION['form_data']['id_app'] = $app;
        if (empty($_SESSION['errors'])) {
            // Propose a description based on the appointment
            $_SESSION['form_data']['description'] = _T('fu_info_after_event', array('title' => _Ti(_Tkw('appointments', $row['type'])) . $row['title'], 'date' => format_date($row['start_time']), 'participants' => join(', ', $participants)));
            $_SESSION['form_data']['date_start'] = $row['start_time'];
            $_SESSION['form_data']['date_end'] = $row['end_time'];
            $_SESSION['form_data']['description'] = str_replace('&nbsp;', ' ', $_SESSION['form_data']['description']);
        }
    }
}
Ejemplo n.º 19
0
function show_attachments_list($type, $id_type, $id_author = 0)
{
    if (!($type == 'case' || $type == 'client' || $type == 'org')) {
        lcm_panic("unknown type -" . $type . "-");
    }
    $q = "SELECT * \n\t\t\tFROM lcm_" . $type . "_attachment \n\t\t\tWHERE content IS NOT NULL ";
    if ($id_type) {
        $q .= " AND id_" . $type . " = " . intval($id_type);
    }
    if ($id_author) {
        $q .= " AND id_author = " . intval($id_author);
    }
    $result = lcm_query($q);
    $i = lcm_num_rows($result);
    if ($i > 0) {
        echo '<table border="0" align="center" class="tbl_usr_dtl" width="99%">' . "\n";
        echo "<tr>\n";
        if ($id_author) {
            echo '<th class="heading" width="1%">' . _Th($type . '_input_id') . "</th>\n";
        }
        echo '<th class="heading">' . _Th('file_input_type') . "</th>\n";
        echo '<th class="heading">' . _Th('file_input_description') . "</th>\n";
        echo '<th class="heading">' . _Th('file_input_size') . "</th>\n";
        echo '<th class="heading">' . "</th>\n";
        echo "</tr>\n";
        for ($i = 0; $row = lcm_fetch_array($result); $i++) {
            echo "<tr>\n";
            if ($id_author) {
                echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '" align="left">';
                echo '<a href="' . $type . '_det.php?' . $type . '=' . $row['id_' . $type] . '" class="content_link">' . $row['id_' . $type] . '</a>';
                echo "</td>\n";
            }
            // Mimetype
            // [ML] We were using the mimetype sent by the browser, but it
            // ends up being rather useless, since MSIE and Firefox don't agree on
            // the mimetypes.. ex: .jpg = image/jpeg (FFx), but under MSIE is image/pjeg
            // So may as well just use the extention of the file, even if not reliable.
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '" align="left">';
            echo '<a title="' . $row['type'] . '" ' . 'href="view_file.php?type=' . $type . '&amp;file_id=' . $row['id_attachment'] . '">';
            if (preg_match("/\\.([a-zA-Z0-9]+)\$/", $row['filename'], $regs) && is_file("images/mimetypes/" . strtolower($regs[1]) . ".png")) {
                echo '<img src="images/mimetypes/' . $regs[1] . '.png" border="0" alt="' . $row['type'] . '" />';
            } else {
                echo '<img src="images/mimetypes/unknown.png" border="0" alt="' . $row['type'] . '" />';
            }
            echo '</a>';
            echo '</td>';
            // File name (or description, if any)
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . '<a title="' . $row['filename'] . '" ' . 'href="view_file.php?type=' . $type . '&amp;file_id=' . $row['id_attachment'] . '" class="content_link">';
            echo trim($row['description']) ? $row['description'] : $row['filename'];
            echo '</a></td>';
            // Size
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . size_in_bytes($row['size']) . '</td>';
            // Delete icon
            echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">';
            if ($GLOBALS['author_session']['status'] == 'admin' || $row['id_author'] == $GLOBALS['author_session']['id_author'] && ($type == 'case' ? allowed($id_type, 'e') : true)) {
                echo '<label for="id_rem_file' . $row['id_attachment'] . '">';
                echo '<img src="images/jimmac/stock_trash-16.png" width="16" height="16" ' . 'alt="' . _T('file_info_delete') . '" title="' . _T('file_info_delete') . '" />';
                echo '</label>&nbsp;';
                echo '<input type="checkbox" onclick="lcm_show(\'btn_delete\')" ' . 'id="id_rem_file' . $row['id_attachment'] . '" name="rem_file[]" ' . 'value="' . $row['id_attachment'] . '" />';
            }
            echo '</td>';
            echo "</tr>\n";
        }
        echo "</table>\n";
        echo '<p align="right" style="visibility: hidden">';
        echo '<input type="submit" name="submit" id="btn_delete" value="' . _T('button_validate') . '" class="search_form_btn" />';
        echo "</p>\n";
    } else {
        echo '<p class="normal_text">' . _T('file_info_emptylist') . "</p>\n";
    }
}