Exemple #1
0
        <li>
            <?php 
// Draw footer menu
Menu::DrawFooterMenu();
?>
		  
        </li>
    </ul>
    <form name="frmLogout" id="frmLogout" style="padding:0px;margin:0px;" action="index.php" method="post">
    <p>
        <?php 
echo $footer_text = $objSiteDescription->DrawFooter(false);
?>
        <?php 
if (!empty($footer_text)) {
    echo '&nbsp;' . draw_divider(false) . '&nbsp;';
}
?>
        <?php 
if ($objLogin->IsLoggedIn()) {
    ?>
            <?php 
    draw_hidden_field('submit_logout', 'logout');
    ?>
            <a class="main_link" href="javascript:appFormSubmit('frmLogout');"><?php 
    echo _BUTTON_LOGOUT;
    ?>
</a>
        <?php 
} else {
    ?>
    public function DrawViewMode()
    {
        $this->IncludeJSFunctions();
        $this->BeforeViewRecords();
        $sorting_fields = self::GetParameter('sorting_fields');
        $sorting_types = self::GetParameter('sorting_types');
        $page = self::GetParameter('page');
        $total_pages = $page;
        $rid = self::GetParameter('rid');
        $action = self::GetParameter('action');
        $operation = self::GetParameter('operation');
        $operation_type = self::GetParameter('operation_type');
        $operation_field = self::GetParameter('operation_field');
        $search_status = self::GetParameter('search_status');
        $concat_sign = preg_match('/\\?/', $this->formActionURL) ? '&' : '?';
        $colspan = count($this->arrViewModeFields) + 1;
        $start_row = 0;
        $total_records = 0;
        $sort_by = '';
        $export_content = array();
        $calendar_fields = array();
        $nl = "\n";
        // prepare changing of language
        //----------------------------------------------------------------------
        if ($operation == 'change_language' && $operation_type != '' && strlen($operation_type) == 2) {
            $this->languageId = $operation_type;
            // added to prevent search with entered word on changing language
            $search_status = '';
        }
        // prepare sorting data
        //----------------------------------------------------------------------
        if ($this->isSortingAllowed) {
            if ($operation == 'sorting') {
                if ($sorting_fields != '') {
                    if ($action == 'delete') {
                        // $sorting_types
                    } else {
                        if (strtolower($sorting_types) == 'asc') {
                            $sorting_types = 'DESC';
                        } else {
                            $sorting_types = 'ASC';
                        }
                    }
                    $sort_type = isset($this->arrViewModeFields[$sorting_fields]['sort_type']) ? $this->arrViewModeFields[$sorting_fields]['sort_type'] : 'string';
                    $sort_by = isset($this->arrViewModeFields[$sorting_fields]['sort_by']) ? $this->arrViewModeFields[$sorting_fields]['sort_by'] : $sorting_fields;
                    if ($sort_type == 'numeric') {
                        $this->ORDER_CLAUSE = ' ORDER BY ABS(' . $sort_by . ') ' . $sorting_types . ' ';
                    } else {
                        $this->ORDER_CLAUSE = ' ORDER BY ' . $sort_by . ' ' . $sorting_types . ' ';
                    }
                } else {
                    $sorting_types = 'ASC';
                }
            } else {
                if ($sorting_fields != '' && $sorting_types != '') {
                    $this->ORDER_CLAUSE = ' ORDER BY ' . $sorting_fields . ' ' . $sorting_types . ' ';
                }
            }
        }
        // prepare filtering data
        //----------------------------------------------------------------------
        if ($this->isFilteringAllowed) {
            if ($search_status == 'active') {
                if ($this->WHERE_CLAUSE == '') {
                    $this->WHERE_CLAUSE .= ' WHERE 1=1 ';
                }
                $count = 0;
                foreach ($this->arrFilteringFields as $key => $val) {
                    $custom_handler = isset($val['custom_handler']) ? $val['custom_handler'] : false;
                    if (!$custom_handler && self::GetParameter('filter_by_' . $val['table'] . $val['field'], false) !== '') {
                        $sign = '=';
                        $sign_start = '';
                        $sign_end = '';
                        if ($val['sign'] == '=') {
                            $sign = '=';
                        } else {
                            if ($val['sign'] == '>=') {
                                $sign = '>=';
                            } else {
                                if ($val['sign'] == '<=') {
                                    $sign = '<=';
                                } else {
                                    if ($val['sign'] == 'like%') {
                                        $sign = 'LIKE';
                                        $sign_end = '%';
                                    } else {
                                        if ($val['sign'] == '%like') {
                                            $sign = 'LIKE';
                                            $sign_start = '%';
                                        } else {
                                            if ($val['sign'] == '%like%') {
                                                $sign = 'LIKE';
                                                $sign_start = '%';
                                                $sign_end = '%';
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        $key_value = self::GetParameter('filter_by_' . $val['table'] . $val['field'], false);
                        if (isset($val['table']) && $val['table'] != '') {
                            $field_name = $val['table'] . '.' . $val['field'];
                        } else {
                            $field_name = $val['field'];
                        }
                        $date_format = isset($val['date_format']) ? $val['date_format'] : '';
                        $type = isset($val['type']) ? $val['type'] : '';
                        if ($type == 'calendar') {
                            $key_value = $this->PrepareDateTime($key_value, $date_format);
                        }
                        if ($this->IsSecureField($key, $val)) {
                            $field_name = $this->UncryptValue($field_name, $val, false);
                        }
                        $this->WHERE_CLAUSE .= ' AND ' . $field_name . ' ' . $sign . ' \'' . $sign_start . mysql_real_escape_string($key_value) . $sign_end . '\' ';
                    }
                }
            }
        }
        // prepare paging data
        //----------------------------------------------------------------------
        if ($this->isPagingAllowed) {
            if (!is_numeric($page) || (int) $page <= 0) {
                $page = 1;
            }
            // set sql_mode to empty if you have Mixing of GROUP columns SQL issue - in connection.php file
            /// database_void_query('SET sql_mode = ""');
            $sql = preg_replace('/SELECT\\b/i', 'SELECT COUNT(*) as mg_total_records, ', $this->VIEW_MODE_SQL, 1) . ' ' . $this->WHERE_CLAUSE . ' LIMIT 0, 1';
            if ($this->debug) {
                $start_time = $this->GetFormattedMicrotime();
            }
            $result = database_query($sql, DATA_AND_ROWS, FIRST_ROW_ONLY);
            if ($this->debug) {
                $finish_time = $this->GetFormattedMicrotime();
            }
            $total_records = isset($result[0]['mg_total_records']) ? (int) $result[0]['mg_total_records'] : '1';
            if ($this->debug) {
                if (!mysql_error()) {
                    $this->arrSQLs['total_records_sql'] = '<i>Total Records</i> | T: ' . round((double) $finish_time - (double) $start_time, 4) . ' sec. <br>' . $sql;
                } else {
                    $this->arrErrors['total_records_sql'] = $sql . '<br>' . mysql_error();
                }
            }
            if ($this->pageSize == 0) {
                $this->pageSize = '10';
            }
            $total_pages = (int) ($total_records / $this->pageSize);
            // when you back from other languages where more pages than on current
            if ($page > $total_pages + 1) {
                $page = 1;
            }
            if ($total_records % $this->pageSize != 0) {
                $total_pages++;
            }
            $start_row = ($page - 1) * $this->pageSize;
        }
        // check if there is move operation and perform it
        //----------------------------------------------------------------------
        if ($operation == 'move') {
            // block if this is a demo mode
            if (strtolower(SITE_MODE) == 'demo') {
                $this->error = _OPERATION_BLOCKED;
            } else {
                $operation_field_p = explode('#', $operation_field);
                $operation_field_p0 = explode('-', $operation_field_p[0]);
                $operation_field_p1 = explode('-', $operation_field_p[2]);
                $of_first = isset($operation_field_p0[0]) ? $operation_field_p0[0] : '';
                $of_second = isset($operation_field_p0[1]) ? $operation_field_p0[1] : '';
                $of_name = $operation_field_p[1];
                $of_first_value = isset($operation_field_p1[0]) ? $operation_field_p1[0] : '';
                $of_second_value = isset($operation_field_p1[1]) ? $operation_field_p1[1] : '';
                if ($of_first_value != '' && $of_second_value != '') {
                    $sql = 'UPDATE ' . $this->tableName . ' SET ' . $of_name . ' = \'' . $of_second_value . '\' WHERE ' . $this->primaryKey . ' = \'' . $of_first . '\'';
                    database_void_query($sql);
                    if ($this->debug) {
                        $this->arrSQLs['select_move_1'] = $sql;
                    }
                    $sql = 'UPDATE ' . $this->tableName . ' SET ' . $of_name . ' = \'' . $of_first_value . '\' WHERE ' . $this->primaryKey . ' = \'' . $of_second . '\'';
                    database_void_query($sql);
                    if ($this->debug) {
                        $this->arrSQLs['select_move_2'] = $sql;
                    }
                }
            }
        }
        $arrRecords = $this->GetAll($this->ORDER_CLAUSE, 'LIMIT ' . $start_row . ', ' . (int) $this->pageSize);
        if ($this->allowLanguages) {
            $arrLanguages = Languages::GetAllActive();
        }
        if (!$this->isPagingAllowed) {
            $total_records = $arrRecords[1];
        }
        echo '<form name="frmMicroGrid_' . $this->tableName . '" id="frmMicroGrid_' . $this->tableName . '" action="' . $this->formActionURL . '" method="post">' . $nl;
        draw_hidden_field('mg_prefix', $this->uPrefix);
        echo $nl;
        draw_hidden_field('mg_action', 'view');
        echo $nl;
        draw_hidden_field('mg_rid', '');
        echo $nl;
        draw_hidden_field('mg_sorting_fields', $sorting_fields);
        echo $nl;
        draw_hidden_field('mg_sorting_types', $sorting_types);
        echo $nl;
        draw_hidden_field('mg_page', $page);
        echo $nl;
        draw_hidden_field('mg_operation', $operation);
        echo $nl;
        draw_hidden_field('mg_operation_type', $operation_type);
        echo $nl;
        draw_hidden_field('mg_operation_field', $operation_field);
        echo $nl;
        draw_hidden_field('mg_search_status', $search_status);
        echo $nl;
        draw_hidden_field('mg_language_id', $this->languageId);
        echo $nl;
        draw_hidden_field('mg_operation_code', self::GetRandomString(20));
        echo $nl;
        draw_token_field();
        echo $nl;
        if ($this->actions['add'] || $this->allowLanguages || $this->allowRefresh || $this->isExportingAllowed) {
            echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table">
				<tr>';
            echo '<td align="' . Application::Get('defined_left') . '" valign="middle">';
            if ($this->actions['add']) {
                echo '<input class="mgrid_button" type="button" name="btnAddNew" value="' . _ADD_NEW . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'add\');">&nbsp;&nbsp;&nbsp;';
            }
            if ($this->operationLinks != '') {
                echo $this->operationLinks;
            }
            echo '</td>';
            echo '<td align="' . Application::Get('defined_right') . '" valign="middle">';
            if ($this->isExportingAllowed) {
                if (strtolower(SITE_MODE) == 'demo' || !$arrRecords[1]) {
                    echo '<span class="gray">[ ' . _EXPORT . ' ]</span> &nbsp;';
                } else {
                    if ($operation == 'switch_to_export') {
                        echo '[ <a href="javascript:void(\'export|cancel\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'switch_to_normal\');" title="' . _SWITCH_TO_NORMAL . '">' . _BUTTON_CANCEL . '</a> | ' . _DOWNLOAD . ' - <a href="javascript:void(\'csv\');" onclick="javascript:appGoToPage(\'index.php?admin=export&file=export.csv\')"><img src="images/microgrid_icons/csv.gif" alt="' . _DOWNLOAD . ' CSV"></a> ] &nbsp;';
                    } else {
                        echo '<a href="javascript:void(\'export\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'switch_to_export\');" title="' . _SWITCH_TO_EXPORT . '">[ ' . _EXPORT . ' ]</a> &nbsp;';
                    }
                }
            }
            if ($this->allowRefresh) {
                echo '<a href="javascript:void(\'refresh\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\');" title="' . _REFRESH . '"><img src="images/microgrid_icons/refresh.gif" alt="' . _REFRESH . '"></a>';
            }
            echo '</td>';
            if ($this->allowLanguages) {
                echo '<td align="' . Application::Get('defined_right') . '" width="80px">';
                $this->allowLanguages ? draw_languages_box('mg_language_id', $arrLanguages[0], 'abbreviation', 'lang_name', $this->languageId, '', 'onchange="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', null, null, null, null, \'change_language\', this.value, \'language_id\');"') : '';
                echo '</td>';
            }
            echo '
				</tr>
				<tr><td nowrap height="10px"></td></tr>
			</table>';
        }
        if ($this->isFilteringAllowed) {
            echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table">
				<tr>
					<td align="' . Application::Get('defined_left') . '">';
            echo '<b>' . _FILTER_BY . '</b>: &nbsp;&nbsp;&nbsp;';
            foreach ($this->arrFilteringFields as $key => $val) {
                if (!$this->IsVisible($val)) {
                    continue;
                }
                $filter_field_value = $search_status == 'active' ? self::GetParameter('filter_by_' . $val['table'] . $val['field'], false) : '';
                if ($val['type'] == 'text') {
                    echo $key . ':&nbsp;<input type="text" class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" value="' . $this->GetDataDecoded($filter_field_value) . '" style="width:' . $val['width'] . '" maxlength="125">&nbsp;&nbsp;&nbsp;';
                } else {
                    if ($val['type'] == 'dropdownlist') {
                        if (is_array($val['source'])) {
                            echo $key . ':&nbsp;<select class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" style="width:' . $val['width'] . '">';
                            echo '<option value="">-- ' . _SELECT . ' --</option>';
                            foreach ($val['source'] as $key => $val) {
                                echo '<option ' . ($filter_field_value !== '' && $filter_field_value == $key ? ' selected="selected"' : '') . ' value="' . $this->GetDataDecoded($key) . '">' . $val . '</option>';
                            }
                            echo '</select>&nbsp;&nbsp;&nbsp;';
                        }
                    } else {
                        if ($val['type'] == 'calendar') {
                            $date_format = isset($val['date_format']) ? $val['date_format'] : '';
                            if ($date_format == 'mm/dd/yyyy') {
                                $calendar_date_format = '%m-%d-%Y';
                                $placeholder_date_format = 'mm-dd-yyyy';
                            } else {
                                if ($date_format == 'dd/mm/yyyy') {
                                    $calendar_date_format = '%d-%m-%Y';
                                    $placeholder_date_format = 'dd-mm-yyyy';
                                } else {
                                    $calendar_date_format = '%Y-%m-%d';
                                    $placeholder_date_format = 'yyyy-dd-mm';
                                }
                            }
                            echo $key . ':&nbsp;<input type="text" id="filter_cal' . $val['field'] . '" class="mgrid_text" name="filter_by_' . $val['table'] . $val['field'] . '" value="' . $this->GetDataDecoded($filter_field_value) . '" style="width:' . $val['width'] . '" maxlength="19" placeholder="' . $placeholder_date_format . '">&nbsp;';
                            echo '<img id="filter_cal' . $val['field'] . '_img" src="images/microgrid_icons/cal.gif" alt="" title="' . _SET_TIME . '" style="cursor:pointer;">';
                            echo '&nbsp;&nbsp;';
                            $calendar_fields[] = array('field' => 'filter_cal' . $val['field'], 'format' => $calendar_date_format);
                        }
                    }
                }
            }
            if (count($this->arrFilteringFields) > 0) {
                echo '&nbsp;';
                if ($search_status == 'active') {
                    echo ' <input type="button" class="mgrid_button" name="btnReset" value="' . _BUTTON_RESET . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'\', \'reset_filtering\');">';
                }
                echo ' <input type="button" class="mgrid_button" name="btnSearch" value="' . _SEARCH . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'\', \'filtering\')">';
            }
            echo '	</td>
				</tr>
				<tr><td nowrap height="10px"></td></tr>
			</table>';
        }
        // draw rows
        if ($arrRecords[1] > 0) {
            echo '<table width="100%" border="' . ($this->debug ? '1' : '0') . '" cellspacing="0" cellpadding="2" class="mgrid_table">';
            // draw column headers
            echo '<tr>';
            foreach ($this->arrViewModeFields as $key => $val) {
                $width = isset($val['width']) ? ' width="' . $val['width'] . '"' : '';
                if (isset($val['align']) && $val['align'] == 'left' && Application::Get('defined_left') == 'right') {
                    $align = ' align="right"';
                } else {
                    if (isset($val['align']) && $val['align'] == 'right' && Application::Get('defined_right') == 'left') {
                        $align = ' align="left"';
                    } else {
                        if (isset($val['align'])) {
                            $align = ' align="' . $val['align'] . '"';
                        } else {
                            $align = '';
                        }
                    }
                }
                $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true;
                $sortable = isset($val['sortable']) && $val['sortable'] !== '' ? $val['sortable'] : true;
                $th_class = $key == $sort_by ? ' class="th_sorted"' : '';
                $title = isset($val['title']) ? $val['title'] : '';
                if ($visible) {
                    echo '<th' . $width . $align . $th_class . '>';
                    if ($this->isSortingAllowed && $sortable) {
                        $field_sorting = 'DESC';
                        $sort_icon = '';
                        if ($key == $sorting_fields) {
                            if (strtolower($sorting_types) == 'asc') {
                                $sort_icon = ' <img src="images/microgrid_icons/up.png" alt="" title="asc">';
                            } else {
                                if (strtolower($sorting_types) == 'desc') {
                                    $sort_icon = ' <img src="images/microgrid_icons/down.png" alt="" title="desc">';
                                }
                            }
                            $field_sorting = $sorting_types;
                        }
                        echo '<a href="javascript:void(\'sort\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'' . $key . '\', \'' . $field_sorting . '\', \'' . $page . '\', \'sorting\')"><b>' . $title . '</b></a>' . $sort_icon;
                        $this->DrawHeaderTooltip($val);
                    } else {
                        echo '<label>' . $title . '</label>';
                    }
                    echo '</th>';
                    if ($operation == 'switch_to_export' && strtolower(SITE_MODE) != 'demo') {
                        $export_content[0][] = $val['title'];
                    }
                }
            }
            if ($this->actions['details'] || $this->actions['edit'] || $this->actions['delete']) {
                echo '<th width="8%">' . _ACTIONS . '</th>';
            }
            echo '</tr>';
            echo '<tr><td colspan="' . $colspan . '" height="3px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>';
            for ($i = 0; $i < $arrRecords[1]; $i++) {
                echo '<tr ' . ($this->isAlterColorsAllowed ? highlight(0) : '') . '>';
                foreach ($this->arrViewModeFields as $key => $val) {
                    if (isset($val['align']) && $val['align'] == 'left' && Application::Get('defined_left') == 'right') {
                        $align = ' align="right"';
                    } else {
                        if (isset($val['align']) && $val['align'] == 'right' && Application::Get('defined_right') == 'left') {
                            $align = ' align="left"';
                        } else {
                            if (isset($val['align'])) {
                                $align = ' align="' . $val['align'] . '"';
                            } else {
                                $align = '';
                            }
                        }
                    }
                    $wrap = isset($val['nowrap']) && $val['nowrap'] == 'nowrap' ? ' nowrap="' . $val['nowrap'] . '"' : ' wrap';
                    $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true;
                    $movable = isset($val['movable']) && $val['movable'] !== '' ? $val['movable'] : false;
                    if (isset($arrRecords[0][$i][$key])) {
                        $field_value = $this->DrawFieldByType('view', $key, $val, $arrRecords[0][$i], false);
                        if ($this->isAggregateAllowed && isset($this->arrAggregateFields[$key])) {
                            $key_agreg = isset($this->arrAggregateFields[$key]['aggregate_by']) && $this->arrAggregateFields[$key]['aggregate_by'] !== '' ? $this->arrAggregateFields[$key]['aggregate_by'] : $key;
                            if (!isset($this->arrAggregateFieldsTemp[$key])) {
                                $this->arrAggregateFieldsTemp[$key] = array('sum' => $arrRecords[0][$i][$key_agreg], 'count' => 1);
                            } else {
                                $this->arrAggregateFieldsTemp[$key]['sum'] += $arrRecords[0][$i][$key_agreg];
                                $this->arrAggregateFieldsTemp[$key]['count']++;
                            }
                        }
                    } else {
                        if ($this->debug) {
                            $this->arrWarnings['wrong_' . $key] = 'Field <b>' . $key . '</b>: wrong definition in View mode or at least one field has no value in SQL! Please check currefully your code.';
                        }
                        $field_value = '';
                    }
                    if ($visible) {
                        $move_link = '';
                        if ($movable) {
                            $move_prev_id = $arrRecords[0][$i]['id'] . '-' . (isset($arrRecords[0][$i - 1]['id']) ? $arrRecords[0][$i - 1]['id'] : '') . '#';
                            $move_prev_id .= $key . '#';
                            $move_prev_id .= $arrRecords[0][$i][$key] . '-' . (isset($arrRecords[0][$i - 1][$key]) ? $arrRecords[0][$i - 1][$key] : '');
                            $move_next_id = $arrRecords[0][$i]['id'] . '-' . (isset($arrRecords[0][$i + 1]['id']) ? $arrRecords[0][$i + 1]['id'] : '') . '#';
                            $move_next_id .= $key . '#';
                            $move_next_id .= $arrRecords[0][$i][$key] . '-' . (isset($arrRecords[0][$i + 1][$key]) ? $arrRecords[0][$i + 1][$key] : '');
                            if (isset($arrRecords[0][$i - 1]['id'])) {
                                $move_link .= ' <a href="javascript:void(\'move|up\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'' . $arrRecords[0][$i]['id'] . '\', \'\', \'\', \'\', \'move\', \'up\', \'' . $move_prev_id . '\')">';
                                $move_link .= $this->actionIcons ? '<img src="images/microgrid_icons/up.png" style="margin-bottom:2px" alt="" title="' . _UP . '">' : _UP;
                                $move_link .= '</a>';
                            } else {
                                $move_link .= ' <span style="width:11px;height:11px;"></span>';
                            }
                            if (isset($arrRecords[0][$i + 1]['id'])) {
                                $move_link .= '<a href="javascript:void(\'move|down\');" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'' . $arrRecords[0][$i]['id'] . '\', \'\', \'\', \'\', \'move\', \'down\', \'' . $move_next_id . '\')">';
                                $move_link .= $this->actionIcons ? '<img src="images/microgrid_icons/down.png" style="margin-top:2px" alt="" title="' . _DOWN . '">' : (isset($arrRecords[0][$i - 1]['id']) ? '/' : '') . _DOWN;
                                $move_link .= '</a>';
                            } else {
                                $move_link .= '<span style="width:11px;height:11px;"></span>';
                            }
                        }
                        echo '<td' . $align . $wrap . '>' . $field_value . $move_link . '</td>';
                        if ($operation == 'switch_to_export' && strtolower(SITE_MODE) != 'demo') {
                            $export_content[$i + 1][] = str_replace(',', '', strip_tags($field_value));
                        }
                    }
                }
                if ($this->actions['details'] || $this->actions['edit'] || $this->actions['delete']) {
                    echo '<td align="center" nowrap="nowrap">';
                    if ($this->actions['details']) {
                        echo '<a href="javascript:void(\'details|' . $arrRecords[0][$i][$this->primaryKey] . '\');" title="' . _VIEW_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'details\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/details.gif" title="' . _VIEW_WORD . '" alt="" border="0" style="margin:0px; padding:0px;" height="16px">' : _VIEW_WORD) . '</a>';
                    }
                    if ($this->actions['edit']) {
                        if ($this->actions['details']) {
                            echo '&nbsp;' . ($this->actionIcons ? '&nbsp;' : '') . draw_divider(false) . '&nbsp';
                        }
                        echo '<a href="javascript:void(\'edit|' . $arrRecords[0][$i][$this->primaryKey] . '\')" title="' . _EDIT_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'edit\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/edit.gif" title="' . _EDIT_WORD . '" alt="" border="0" style="margin:0px;padding:0px;" height="16px">' : _EDIT_WORD) . '</a>';
                    }
                    if ($this->actions['delete']) {
                        if ($this->actions['edit'] || $this->actions['details']) {
                            echo '&nbsp;' . ($this->actionIcons ? '&nbsp;' : '') . draw_divider(false) . '&nbsp';
                        }
                        echo '<a href="javascript:void(\'delete|' . $arrRecords[0][$i][$this->primaryKey] . '\')" title="' . _DELETE_WORD . '" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'delete\', \'' . $arrRecords[0][$i]['id'] . '\')">' . ($this->actionIcons ? '<img src="images/microgrid_icons/delete.gif" title="' . _DELETE_WORD . '" alt="" border="0" style="margin:0px;padding:0px;" height="16px">' : _DELETE_WORD) . '</a>';
                    }
                    echo '&nbsp;</td>';
                }
                echo '</tr>';
            }
            // for
            // draw aggregate fields row
            if ($this->isAggregateAllowed) {
                echo '<tr><td colspan="' . $colspan . '" height="5px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>';
                echo '<tr>';
                foreach ($this->arrViewModeFields as $key => $val) {
                    $visible = isset($val['visible']) && $val['visible'] !== '' ? $val['visible'] : true;
                    if ($visible) {
                        $ag_field_total = isset($this->arrAggregateFieldsTemp[$key]) ? $this->arrAggregateFieldsTemp[$key]['sum'] : 0;
                        $ag_field_count = isset($this->arrAggregateFieldsTemp[$key]) ? $this->arrAggregateFieldsTemp[$key]['count'] : 0;
                        $ag_field_function = strtoupper(isset($this->arrAggregateFields[$key]['function']) ? $this->arrAggregateFields[$key]['function'] : '');
                        $ag_field_align = strtoupper(isset($this->arrAggregateFields[$key]['align']) ? $this->arrAggregateFields[$key]['align'] : 'center');
                        $ag_decimal_place = isset($this->arrAggregateFields[$key]['decimal_place']) ? (int) $this->arrAggregateFields[$key]['decimal_place'] : 2;
                        $ag_field_value = '';
                        if ($ag_field_function == 'SUM') {
                            $ag_field_value = $ag_field_count != 0 ? number_format($ag_field_total, $ag_decimal_place) : '';
                        } else {
                            if ($ag_field_function == 'AVG') {
                                $ag_field_value = $ag_field_count != 0 ? number_format($ag_field_total / $ag_field_count, $ag_decimal_place) : '';
                            }
                        }
                        echo '<td align="' . $ag_field_align . '">' . ($ag_field_function != '' ? $ag_field_function . '=' : '') . $ag_field_value . '</td>';
                    }
                }
                echo '</tr>';
                echo '<tr><td colspan="' . $colspan . '" height="5px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>';
            } else {
                echo '<tr><td colspan="' . $colspan . '" height="15px" nowrap="nowrap">' . draw_line('no_margin_line', IMAGE_DIRECTORY, false) . '</td></tr>';
            }
            echo '</table>';
            echo '<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mgrid_table">';
            echo '<tr valign="top">';
            echo '<td>';
            if ($this->isPagingAllowed) {
                echo '<b>' . _PAGES . ':</b> ';
                for ($i = 1; $i <= $total_pages; $i++) {
                    echo '<a class="paging_link" href="javascript:void(\'paging\')" onclick="javascript:__mgDoPostBack(\'' . $this->tableName . '\', \'view\', \'\', \'\', \'\', \'' . $i . '\', \'\')">' . ($i == $page ? '<b>[' . $i . ']</b>' : $i) . '</a> ';
                }
            }
            echo '</td>';
            echo '<td align="' . Application::Get('defined_right') . '">';
            $row_from = $start_row + 1;
            $row_to = $start_row + $this->pageSize < $total_records ? $start_row + $this->pageSize : $total_records;
            echo '<b>' . _TOTAL . '</b>: ' . ($row_from < $row_to ? $row_from . ' - ' . $row_to : $row_from) . ' / ' . $total_records;
            echo '</td>';
            echo '</tr>';
            echo '</table>';
            // prepare export file
            //----------------------------------------------------------------------
            if ($operation == 'switch_to_export') {
                if (strtolower(SITE_MODE) == 'demo') {
                    $this->error = _OPERATION_BLOCKED;
                } else {
                    $export_content_count = count($export_content);
                    $fe = @fopen('tmp/export/export.csv', 'w+');
                    @fwrite($fe, "");
                    for ($i = 0; $i < $export_content_count; $i++) {
                        @fputcsv($fe, $export_content[$i]);
                    }
                    @fclose($fe);
                }
            }
        } else {
            draw_message(_NO_RECORDS_FOUND, true, true, false, 'width:100%');
            //if($this->debug) $this->arrSQLs['select'] = $this->VIEW_MODE_SQL.' '.$this->WHERE_CLAUSE.' '.$this->ORDER_CLAUSE.' LIMIT '.$start_row.', '.(int)$this->pageSize;
        }
        echo '</form>';
        $this->CalendarSetupFields($calendar_fields);
        $this->AfterViewRecords();
        $this->DrawVersionInfo();
        $this->DrawRunningTime();
        $this->DrawErrors();
        $this->DrawWarnings();
        $this->DrawSQLs();
        $this->DrawPostInfo();
    }
Exemple #3
0
            }
            // prepare menu link for display
            $menu_name = $all_pages[0][$i]['menu_name'];
            if (strlen($menu_name) > 18) {
                $menu_name = substr($menu_name, 0, 18) . '..';
            }
            // display page row
            echo '<tr ' . highlight(0) . ' onmouseover="oldColor=this.style.backgroundColor;this.style.backgroundColor=\'#e7e7e7\';" onmouseout="this.style.backgroundColor=oldColor">
						<td align="' . Application::Get('defined_left') . '">' . $page_header . '</td>
						<td align="center">' . ($menu_name != '' ? $menu_name : _NOT_AVAILABLE) . '</td>
						<td align="center">' . format_datetime($all_pages[0][$i]['status_changed']) . '</td>
						<td align="center">' . ucfirst($all_pages[0][$i]['content_type']) . '</td>
						<td align="center" nowrap>
							' . prepare_permanent_link('index.php?page=pages&pid=' . $all_pages[0][$i]['id'] . '&mg_language_id=' . $language_id, _VIEW_WORD) . '&nbsp;&nbsp;' . draw_divider(false) . '&nbsp;
							' . ($objLogin->HasPrivileges('edit_pages') ? '<a href="javascript:void(0)" onclick="javascript:confirmRestore(\'' . $all_pages[0][$i]['id'] . '\');">' . _RESTORE . '</a>' : '') . '
							' . ($objLogin->HasPrivileges('edit_pages') && $objLogin->HasPrivileges('delete_pages') ? '&nbsp;' . draw_divider(false) . '' : '') . '&nbsp;
							' . ($objLogin->HasPrivileges('delete_pages') ? '<a href="javascript:void(0)" onclick="javascript:confirmDelete(\'' . $all_pages[0][$i]['id'] . '\');">' . _DELETE_WORD . '</a>' : '') . '
						</td>
					</tr>';
        }
        ?>
		</table>
<?php 
    } else {
        echo '<br />';
        draw_important_message(_PAGE_NOT_FOUND, true, true, false, 'width:100%');
    }
    draw_content_end();
} else {
    draw_title_bar(_ADMIN);
    draw_important_message(_NOT_AUTHORIZED);