Ejemplo n.º 1
0
    function display()
    {
        global $CFG;
        if (!is_array($this->tables)) {
            return false;
        }
        $title = $this->rootname ? $this->rootname : Ops::getPageTitle();
        $HTML = '
		<div class="area full_box multi_list ' . $this->class . '" id="mlist_' . $this->i . '">
			<h2>' . $title . '</h2>
			<div class="box_bar"></div>
			<div class="box_tl"></div>
			<div class="box_tr"></div>
			<div class="box_bl"></div>
			<div class="box_br"></div>
			<div class="t_shadow"></div>
			<div class="r_shadow"></div>
			<div class="b_shadow"></div>
			<div class="l_shadow"></div>
			<div class="box_b"></div>
			<div class="grid_buttons"><div class="button before"></div>';
        $HTML .= $this->dragdrop && User::permission(0, 0, $CFG->url) > 1 ? "<a href=\"#\" onclick=\"ml_save(this)\" class=\"button\"><div class=\"save\"></div> {$CFG->save_caption}</a>" : '';
        $HTML .= '<div class="button after"></div></div><div class="contain">';
        $HTML .= MultiList::displayItems($this->tables);
        $HTML .= '<div class="clear"></div></div></div>';
        if ($this->dragdrop && !$CFG->pm_editor) {
            $HTML .= '<script type="text/javascript">';
            foreach ($this->levels as $level => $value) {
                $n = count($value);
                $siblings = $value;
                foreach ($value as $j) {
                    $HTML .= '
					' . (!$CFG->bypass ? '$(document).ready(function(){' : '') . '
						$(".mlist_' . $this->i . '_level_' . $level . '").sortable({
									revert: true,
									cursor: "move",
									opacity: 0.7,
									items: ".li_' . $level . '",
									connectWith: ".mlist_' . $this->i . '_level_' . $level . '"			
						}); 
					' . (!$CFG->bypass ? '});' : '') . '
					';
                }
            }
            $HTML .= '</script>';
        }
        echo $HTML;
    }
Ejemplo n.º 2
0
    function display()
    {
        global $CFG;
        self::executeUpdates();
        // display form
        if (!$this->output_started) {
            if (!$this->has_areas && !strstr($this->name, 'form_filters') && !$CFG->in_popup && $CFG->backstage_mode) {
                echo '
				<div class="area full_box">
					<h2>' . ($CFG->form_legend ? $CFG->form_legend : Ops::getPageTitle()) . '</h2>
					<div class="box_bar"></div>
					<div class="box_tl"></div>
					<div class="box_tr"></div>
					<div class="box_bl"></div>
					<div class="box_br"></div>
					<div class="t_shadow"></div>
					<div class="r_shadow"></div>
					<div class="b_shadow"></div>
					<div class="l_shadow"></div>
					<div class="box_b"></div>
					<div class="contain">';
            }
            if (!$CFG->pm_editor) {
                echo '<form name="' . $this->name . '" action="' . $this->action . '" class="form ' . $this->class . '" method="' . $this->method . '"  ' . $this->enctype . ' ' . $this->target . '>';
            } else {
                echo '<div class="form ' . $this->class . '">';
            }
        }
        if (!$CFG->in_include) {
            $is_tab = $this->go_to_is_tab ? $this->go_to_is_tab : $CFG->is_tab;
            echo '<input type="hidden" id="form_table" name="form_table" value="' . $this->table . '" />';
            echo '<input type="hidden" id="form_name" name="form_name" value="' . $this->name . '" />';
            echo '<input type="hidden" name="is_tab" value="' . $is_tab . '" />';
            if ($CFG->url) {
                $url = $this->go_to_url ? $this->go_to_url : $CFG->url;
                $action = $this->go_to_action ? $this->go_to_action : $CFG->action;
                echo '<input type="hidden" name="current_url" value="' . $url . '" />';
                if ($this->return_to_self) {
                    echo '<input type="hidden" name="id" value="' . $this->record_id . '" />';
                    echo '<input type="hidden" name="action" value="' . $action . '" />';
                    echo '<input type="hidden" name="return_to_self" value="1" />';
                }
            }
            if ($this->go_to_url) {
                echo '<input type="hidden" name="remember_values" value="1"/>';
            }
            echo '<ul>';
        } else {
            echo '
			<input type="hidden" name="includes[' . $this->table . '][name]" value="' . $this->name . '" />
			<input type="hidden" name="includes[' . $this->table . '][id]" value="' . $this->record_id . '" />';
            if (is_array($this->db_fields)) {
                foreach ($this->db_fields as $f_name => $f_type) {
                    echo '<input type="hidden" name="includes[' . $this->table . '][fields][' . $f_name . ']" value="' . $f_type . '" />';
                }
            }
        }
        if (is_array($this->HTML)) {
            $alt = 'alt';
            foreach ($this->HTML as $method_id => $elem) {
                if (!$in_group && !stristr($elem, '<htmlfield>')) {
                    $alt = $alt ? false : 'alt';
                }
                if ($this->current_restricted > 0 && !stristr($elem, '</restricted>')) {
                    $alt = $alt ? false : 'alt';
                    continue;
                } elseif (stristr($elem, '<button>')) {
                    $elem = str_replace('<button>', '', $elem);
                    $alt = 'button_alt';
                } elseif (stristr($elem, '<date_filter_end>')) {
                    $elem = str_replace('<date_filter_end>', '', $elem);
                    $alt = $alt ? false : 'alt';
                } elseif (stristr($elem, '<include>')) {
                    echo str_replace('<include>', '', $elem);
                    continue;
                } elseif (stristr($elem, '<group>')) {
                    $in_group = true;
                    echo str_replace('<group>', '', '<li class="' . $alt . '">' . $elem);
                    continue;
                } elseif (stristr($elem, '</group>')) {
                    $in_group = false;
                    echo str_replace('</group>', '', $elem);
                    continue;
                } elseif (stristr($elem, '<tab>')) {
                    echo str_replace('<tab>', '', $elem);
                    continue;
                } elseif (stristr($elem, '</tab>')) {
                    echo str_replace('</tab>', '', $elem);
                    continue;
                } elseif ($elem == '<captcha>') {
                    if ($CFG->pm_editor) {
                        $method_name = self::peLabel($method_id, 'captcha');
                    }
                    echo "\n\t\t\t\t\t<li class=\"{$alt}\">\n\t\t\t\t\t\t<div class=\"captcha\">\n\t\t\t\t\t\t\t<label for=\"captcha\">{$this->c_caption}{$method_name}</label>\n\t\t\t\t\t\t\t<img id=\"captcha\" src=\"securimage/securimage_show.php\" />\n\t\t\t\t\t\t\t<input type=\"text\" name=\"caco\" />\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"is_caco[{$this->name}]\" value=\"1\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</li>";
                    continue;
                } elseif (stristr($elem, '<htmlfield>')) {
                    if ($CFG->pm_editor && !strstr($this->name, 'form_filters')) {
                        $method_name = self::peLabel($method_id, 'HTML');
                    }
                    echo str_replace('<htmlfield>', '', $elem) . $method_name;
                    $this->group = false;
                    continue;
                } elseif (stristr($elem, '<editor')) {
                    $editor = explode('|||', $elem);
                    $this->textEditor($editor[1], $editor[2], $editor[5], $editor[3], $editor[4], true, $editor[6], $editor[7], $editor[8], $editor[9], $method_id);
                    continue;
                } elseif (stristr($elem, '<new_editor>')) {
                    echo "<li class=\"editor_li {$alt}\">" . str_replace('<new_editor>', '', $elem) . '</li>';
                    continue;
                } elseif (stristr($elem, '<pe_editor')) {
                    $editor = explode('|||', $elem);
                    $this->permissionEditor($editor[1], $editor[2], true);
                    continue;
                } elseif (stristr($elem, '<area>')) {
                    echo str_replace('<area>', '', $elem);
                    continue;
                } elseif (stristr($elem, '</area>')) {
                    echo str_replace('</area>', '', $elem);
                    continue;
                } elseif (stristr($elem, '<restricted>')) {
                    $this->current_restricted = 1;
                    $alt = $alt ? false : 'alt';
                    continue;
                } elseif (stristr($elem, '</restricted>')) {
                    $this->current_restricted = 0;
                    $alt = $alt ? false : 'alt';
                    continue;
                }
                if (!$this->group && !stristr($elem, '<fieldset') && $elem != '</fieldset>' && !stristr($elem, 'class="hidden_input"')) {
                    echo "<li class=\"{$alt}\">";
                }
                echo $elem;
                if (!$this->group && !stristr($elem, '<fieldset') && $elem != '</fieldset>' && !stristr($elem, 'class="hidden_input"')) {
                    echo '</li>';
                }
                if ($this->group) {
                    echo '&nbsp;&nbsp;&nbsp;';
                }
            }
        }
        if (!$CFG->in_include) {
            echo '</ul>';
        }
        // send required fields
        if (is_array($this->required)) {
            foreach ($this->required as $field => $type) {
                echo '<input type="hidden" name="verify_fields[' . $field . ']" value="' . $type . '" />';
            }
        }
        // send db types for fields
        if (is_array($this->db_fields)) {
            foreach ($this->db_fields as $field => $type) {
                echo '<input type="hidden" class="form_db_field" name="db_fields[' . $field . ']" value="' . $type . '" />';
            }
        }
        // send compare fields
        if (is_array($this->compare)) {
            foreach ($this->compare as $field => $value) {
                echo '<input type="hidden" class="compare_fields" name="compare_fields[' . $field . ']" value="' . $value . '" />';
            }
        }
        // send unique fields
        if (is_array($this->unique)) {
            foreach ($this->unique as $field => $value) {
                echo '<input type="hidden" class="unique_fields" name="unique_fields[' . $field . ']" value="' . $value . '" />';
            }
        }
        if (is_array($this->delete_whitespace)) {
            foreach ($this->delete_whitespace as $field) {
                echo '<input type="hidden" name="delete_whitespace[]" value="' . $field . '" />';
            }
        }
        if (is_array($this->color_fields)) {
            foreach ($this->color_fields as $field) {
                echo '<input type="hidden" name="color_fields[]" value="' . $field . '" />';
            }
        }
        if ($this->record_id) {
            echo '<input type="hidden" name="record_id" value="' . $this->record_id . '" />';
        }
        echo '
		<div style="clear:both;"></div>
		<script type="text/javascript">
			startFileSortable();
		</script>';
        if (!$this->output_started) {
            if (!$CFG->pm_editor) {
                echo '</form>';
            } else {
                echo '</div>';
            }
            if (!$this->has_areas && !strstr($this->name, 'form_filters') && !$CFG->in_popup && $CFG->backstage_mode) {
                echo '</div></div>';
            }
        }
    }
Ejemplo n.º 3
0
	</div>
	<div class="clear"></div>
	<div class="main_menu">
<?php 
        if ($CFG->url != 'edit_page') {
            ?>
		<div class="menu_item">
			<?php 
            echo Link::url('index.php', '<div class="home_icon"></div>');
            ?>
		</div>
		<?php 
            $tabs = Ops::getTabs();
            if ($tabs) {
                foreach ($tabs as $tab) {
                    $pages = Ops::getPages($tab['id']);
                    $c = count($pages);
                    $split = false;
                    $width_class = false;
                    if ($c > 10) {
                        $split = ceil($c / 3);
                        $width_class = 'triple';
                    } elseif ($c > 5) {
                        $split = ceil($c / 2);
                        $width_class = 'double';
                    }
                    echo '
					<div class="menu_item">
						' . Link::url($tab['url'], $tab['name'] . ($pages ? '<div class="drop"></div>' : ''), false, array('is_tab' => 1));
                    if ($pages) {
                        $i = 0;
Ejemplo n.º 4
0
    function display()
    {
        global $CFG;
        $pm_method = $CFG->pm_editor ? ' class="pm_method"' : '';
        if ($this->HTML) {
            if (!$CFG->in_include) {
                $class = !$this->has_areas ? 'area full_box' : false;
                echo '<div class="record_container ' . $class . '">';
                if (!$this->has_areas && !strstr($this->name, 'form_filters') && !$CFG->in_popup) {
                    echo '
					<h2>' . Ops::getPageTitle() . '</h2>
					<div class="box_bar"></div>
					<div class="box_tl"></div>
					<div class="box_tr"></div>
					<div class="box_bl"></div>
					<div class="box_br"></div>
					<div class="t_shadow"></div>
					<div class="r_shadow"></div>
					<div class="b_shadow"></div>
					<div class="l_shadow"></div>
					<div class="box_b"></div>
					<div class="contain">';
                }
                echo '<ul class="record">';
            }
            $alt = 'alt';
            foreach ($this->HTML as $row) {
                if (!$in_group) {
                    $alt = $alt ? false : 'alt';
                }
                if (stristr($row, '<button>')) {
                    $row = str_replace('<button>', '', $row);
                    $alt = 'button_alt';
                }
                if ($this->current_restricted > 0 && !stristr($row, '</restricted>')) {
                    continue;
                } elseif (strstr($row, '|||')) {
                    echo str_replace('|||', '', $row);
                } elseif (strstr($row, '<area>')) {
                    echo str_replace('<area>', '', $row);
                } elseif (strstr($row, '</area>')) {
                    echo str_replace('</area>', '', $row);
                } elseif (stristr($row, '<group>')) {
                    echo "<li class=\"{$alt}\">" . str_replace('<group>', '', $row);
                    $in_group = true;
                    continue;
                } elseif (stristr($row, '</group>')) {
                    echo str_replace('</group>', '', $row);
                    $in_group = false;
                    continue;
                } elseif (stristr($row, '<tab>')) {
                    echo str_replace('<tab>', '', $row);
                    continue;
                } elseif (stristr($row, '</tab>')) {
                    echo str_replace('</tab>', '', $row);
                    continue;
                } elseif (stristr($row, '<restricted>')) {
                    $this->current_restricted = 1;
                    continue;
                } elseif (stristr($row, '</restricted>')) {
                    $this->current_restricted = 0;
                    continue;
                } else {
                    echo "<li class=\"{$alt}\" {$pm_method}>{$row}<div class=\"clear\"></div></li>";
                }
            }
            if (!$CFG->in_include) {
                echo '<div class="clear"></div></ul>';
                if (!$this->has_areas && !strstr($this->name, 'form_filters') && !$CFG->in_popup) {
                    echo '</div>';
                }
                echo '</div>';
            }
        }
    }
Ejemplo n.º 5
0
    function display($page = 0)
    {
        global $CFG;
        $filters = self::getFilterResults();
        $page = $page > 0 ? $page : $_SESSION['page' . $this->i];
        $_SESSION['page' . $this->i] = $page;
        $page = !($page > 0) || $_REQUEST['submit'] || $this->order_asc_changed || $this->order_by_changed ? 1 : $page;
        $fields = DB::getTableFields($this->table);
        $total_rows = DB::get($this->table, $this->fields, $page, $this->rows_per_page, $this->order_by, $this->order_asc, 1, $filters, $this->inset_id, $this->inset_id_field, false, false, false, false, false, false, false, $this->sql_filter, $this->group_by, $this->no_group_by);
        $data = DB::get($this->table, $this->fields, $page, $this->rows_per_page, $this->order_by, $this->order_asc, 0, $filters, $this->inset_id, $this->inset_id_field, false, false, false, false, false, false, false, $this->sql_filter, $this->group_by, $this->no_group_by);
        $HTML = "";
        if ($CFG->backstage_mode && User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1 && $this->inset_id === false) {
            $HTML .= '
			<form id="grid_form_' . $this->table . $this->i . '" name="grid_form_' . $this->table . $this->i . '" action="' . $CFG->self . '" method="POST">
				<input type="hidden" name="current_url" value="' . $CFG->url . '" />
				<input type="hidden" name="action" value="" />
				<input type="hidden" name="return_to_self" value="1" />';
            if (is_array($this->fields)) {
                foreach ($this->fields as $properties) {
                    if ($properties['aggregate_function']) {
                        $i_name = $properties['name'];
                        switch ($properties['aggregate_function']) {
                            case 'grand_total':
                                $grand_total[$i_name] = 0;
                                break;
                            case 'page_total':
                                $page_total[$i_name] = 0;
                                break;
                            case 'grand_avg':
                                $grand_avg[$i_name] = array();
                                break;
                            case 'page_avg':
                                $page_avg[$i_name] = array();
                                break;
                            case 'both_total':
                                $page_total[$i_name] = 0;
                                $grand_total[$i_name] = 0;
                                break;
                            case 'both_avg':
                                $page_avg[$i_name] = array();
                                $grand_avg[$i_name] = array();
                                break;
                        }
                    }
                }
            }
            if (is_array($this->fields)) {
                foreach ($this->fields as $properties) {
                    if ($properties['cumulative_function']) {
                        $i_name = $properties['name'];
                        if ($properties['cumulative_function'] == 'sum') {
                            $page_total[$i_name] = 0;
                            if ($grand_total) {
                                $grand_total[$i_name] = 0;
                            }
                        } elseif ($properties['cumulative_function'] == 'avg') {
                            $page_avg[$i_name] = array();
                            if ($grand_avg) {
                                $grand_avg[$i_name] = array();
                            }
                        }
                    }
                }
            }
        }
        if ($this->mode == 'list') {
            $HTML .= "<ul class=\"grid_list\">";
            if (is_array($data)) {
                $j = 0;
                foreach ($data as $row) {
                    $HTML .= "<li><ul>";
                    if (is_array($this->fields)) {
                        foreach ($this->fields as $name => $properties) {
                            $key = $name;
                            if (strstr($name, 'lll')) {
                                $name_parts = explode('lll', $name);
                                $name = $name_parts[0];
                            }
                            if ($this->inset_id > 0 && $name == $this->inset_id_field) {
                                continue;
                            }
                            $value = $row[$key];
                            $link_id = $row[$name . '_id'] ? $row[$name . '_id'] : $value;
                            $class = $properties['class'] ? "class=\"{$properties['class']}\"" : '';
                            if ($CFG->pm_editor) {
                                $method_name = Form::peLabel($properties['method_id'], 'field');
                            }
                            $HTML .= "<li {$class}>" . $method_name . "";
                            if (!empty($properties['is_media'])) {
                                reset($CFG->image_sizes);
                                $m_values = explode('|||', $value);
                                $m_size = !empty($properties['media_size']) ? $properties['media_size'] : key($CFG->image_sizes);
                                $m_limit = !empty($properties['media_amount']) ? $properties['media_amount'] : 1;
                                $HTML .= Gallery::multiple($properties['subtable'], $row['id'], $properties['name'], $properties['media_size'], 0, false, $properties['media_amount'], false, false, true);
                                $HTML .= '<div class="clear"></div>';
                            } else {
                                if ($fields[$name]['Type'] == 'datetime' || @in_array($name, $foreign_dates)) {
                                    $value = date($CFG->default_date_format, strtotime($value));
                                } elseif ($fields[$name]['Type'] == "enum('Y','N')") {
                                    $value = $value == 'Y' ? '<div class="y_icon"></div>' : '<div class="n_icon"></div>';
                                }
                                if ($value['filter']) {
                                    $order_asc = $this->order_asc ? false : true;
                                    if ($this->order_by == $name) {
                                        $dir_img = $this->order_asc ? $CFG->up : $CFG->down;
                                    } else {
                                        $dir_img = false;
                                    }
                                    $HTML .= '<b>' . Link::url($this->link_url, $properties['header_caption'] . $dir_img, "filter{$this->i}={$name}&order_by{$this->i}={$this->order_by}&order_asc{$this->i}={$order_asc}&is_tab={$this->is_tab}", $this->filter_results, false, 'content') . ':</b> ';
                                } else {
                                    $HTML .= $this->show_list_captions ? '<b>' . $properties['header_caption'] . ':</b> ' : '';
                                }
                                if (empty($properties['link_url'])) {
                                    $HTML .= str_ireplace('|||', ' ', $value);
                                } else {
                                    $action = $CFG->backstage_mode ? '&action=record' : '';
                                    $value = str_replace('|||', ' ', $value);
                                    if (!empty($value)) {
                                        $HTML .= Link::url($properties['link_url'], $value, "id={$link_id}&is_tab={$properties['link_is_tab']}{$action}", false, false, $this->target_elem_id);
                                    }
                                }
                                if (is_array($page_total)) {
                                    if (array_key_exists($name, $page_total)) {
                                        $page_total[$name] += $value;
                                    }
                                }
                                if (is_array($page_avg)) {
                                    if (array_key_exists($name, $page_avg)) {
                                        $page_avg[$name][] = $value;
                                    }
                                }
                            }
                            $HTML .= "</li>";
                        }
                    }
                    if ($this->show_buttons) {
                        $HTML .= '<li><nobr>' . ($CFG->backstage_mode ? "<span><label for=\"{$row['id']}\">Select:</label><input id=\"{$row['id']}\" type=\"checkbox\" value=\"{$row['id']}\" class=\"grid_select checkbox_input\"/></span>" : '');
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 0) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=record&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'view', false, false, false, false, $CFG->view_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=form&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'edit', false, false, false, false, $CFG->edit_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1) {
                            $HTML .= '<a href="#" class="delete" title="' . $CFG->delete_hover_caption . '" onclick="gridDelete(' . $row['id'] . ',\'' . $this->table . '\',this)"></a></li>';
                        }
                    }
                    $HTML .= '</nobr></li></ul>';
                    $j++;
                }
            } else {
                $HTML .= '<li>' . $CFG->grid_no_results . '</li>';
            }
            $HTML .= "</ul>";
        } elseif ($this->mode == 'graph' || $this->mode == 'graph_line' || $this->mode == 'graph_pie') {
            $name_column = $this->graph_name_column;
            $y_axis = $this->graph_value_column;
            $x_axis = $this->graph_x_axis;
            if (is_array($this->fields)) {
                foreach ($this->fields as $name => $properties) {
                    if (strstr($fields[$name]['Type'], 'varchar') || !$properties['is_op'] && !empty($properties['subtable'])) {
                        if (!$name_column) {
                            $name_column = $name;
                        }
                        $this->name_columns[$name] = $properties['header_caption'];
                    } elseif (strstr($fields[$name]['Type'], 'date')) {
                        if (!$x_axis) {
                            $x_axis = $name;
                        }
                        $this->x_columns[$name] = $properties['header_caption'];
                    } elseif (($properties['is_op'] || strstr($fields[$name]['Type'], 'int') || strstr($fields[$name]['Type'], 'double')) && $name != 'id' && empty($properties['subtable'])) {
                        if (!$y_axis) {
                            $y_axis = $name;
                        }
                        $this->value_columns[$name] = $properties['header_caption'];
                    }
                }
            }
            if ($data) {
                foreach ($data as $row) {
                    $x_values[] = strtotime($row[$x_axis]);
                    $y_values[] = $row[$y_axis];
                }
                $days = (max($x_values) - min($x_values)) / 86400;
                $max_x = max($x_values);
                $min_x = min($x_values);
                $timestamp = $min_x;
                if ($days <= 30) {
                    $time_unit = 'days';
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp += 86400;
                    }
                } elseif ($days > 30 && $days <= 183) {
                    $time_unit = 'weeks';
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp += 86400 * 7;
                    }
                } elseif ($days > 183 && $days <= 910) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 1 month')));
                    }
                } elseif ($days > 910 && $days <= 1820) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 2 months')));
                    }
                } elseif ($days > 1820 && $days <= 3640) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 4 months')));
                    }
                } elseif ($days > 3640 && $days <= 7280) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 6 months')));
                    }
                } elseif ($days > 7280 && $days <= 14560) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 8 months')));
                    }
                } elseif ($days > 14560 && $days <= 29120) {
                    $time_unit = 'months';
                    $timestamp = strtotime(date('n/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('n/1/Y', strtotime($p_name . ' + 10 months')));
                    }
                } elseif ($days > 29120 && $days <= 58240) {
                    $time_unit = 'years';
                    $timestamp = strtotime(date('1/1/Y', $min_x));
                    while ($timestamp <= $max_x) {
                        $time_units[] = $timestamp;
                        $timestamp = strtotime(date('1/1/Y', strtotime($p_name . ' + 1 year')));
                    }
                }
                $reps = 0;
                foreach ($data as $row) {
                    if (is_array($this->fields)) {
                        $name_value = $this->graph_combine != 'Y' ? $row[$name_column] : 'All';
                        $c_units = count($time_units);
                        $x_val = strtotime($row[$x_axis]);
                        for ($i = 0; $i < $c_units; $i++) {
                            if ($x_val >= $time_units[$i] && ($x_val < $time_units[$i + 1] || !$time_units[$i + 1])) {
                                $x_current = $time_units[$i];
                                break;
                            }
                        }
                        $key = $x_current;
                        if ($x_prev != $x_current) {
                            $y_current = false;
                            $reps = 0;
                        }
                        if ($this->fields[$y_axis]['is_op'] && !$this->fields[$y_axis]['run_in_sql']) {
                            $y_current = self::doOperation($y_axis, $this->fields[$y_axis], $row, $name_value);
                        } else {
                            $y_current = $y_current + $row[$y_axis];
                        }
                        $x_prev = $x_current;
                        if ($this->mode != 'graph_pie') {
                            if (!$graph_data[$name_value][$key]) {
                                $graph_data[$name_value][$key] = $y_current;
                            } else {
                                if ($this->fields[$y_axis]['cumulative_function'] == 'avg') {
                                    $graph_data[$name_value][$key] = ($graph_data[$name_value][$key] + $y_current) / $reps;
                                } else {
                                    $graph_data[$name_value][$key] += $y_current;
                                }
                            }
                        } else {
                            if (!$graph_data[1][$name_value]) {
                                $graph_data[1][$name_value] = $y_current;
                            } else {
                                if ($this->fields[$y_axis]['cumulative_function'] == 'avg') {
                                    $graph_data[1][$name_value] = ($graph_data[1][$name_value] + $y_current) / $reps;
                                } else {
                                    $graph_data[1][$name_value] += $y_current;
                                }
                            }
                        }
                        $titles[$name_value] = $name_value;
                        $reps++;
                    }
                }
                if ($this->mode != 'graph_pie') {
                    foreach ($graph_data as $name_value => $val) {
                        $last_value = 0;
                        foreach ($time_units as $unit) {
                            $key = $unit;
                            if (!array_key_exists($key, $graph_data[$name_value])) {
                                if (!empty($this->fields[$y_axis]['cumulative_function'])) {
                                    $graph_data[$name_value][$key] = $last_value;
                                } else {
                                    $graph_data[$name_value][$key] = 0;
                                }
                            } else {
                                $last_value = $graph_data[$name_value][$key];
                            }
                        }
                    }
                    foreach ($graph_data as $name_value => $val) {
                        ksort($graph_data[$name_value]);
                        $last_value = 0;
                        foreach ($graph_data[$name_value] as $key => $val) {
                            if ($time_unit == 'days' || $time_unit == 'weeks') {
                                $key1 = date('M j', $key);
                            } elseif ($time_unit == 'months') {
                                $key1 = date('M', $key);
                            } elseif ($time_unit == 'years') {
                                $key1 = date('Y', $key);
                            }
                            $graph_data1[$name_value][$key1] = $val;
                        }
                    }
                } else {
                    $graph_data1 = $graph_data;
                }
            }
            $HTML .= '<img class="graph" src="includes/graph.php?graph_data=' . urlencode(serialize($graph_data1)) . '&titles=' . urlencode(serialize($titles)) . '&mode=' . $this->mode . '">';
        } else {
            $HTML .= "<table><tr class=\"grid_header\">";
            if ($CFG->backstage_mode && !$this->links_out && $this->show_buttons && $CFG->is_ctrl_panel != 'Y') {
                $HTML .= "<th><label for=\"grid_select{$this->i}\"/><input id=\"grid_select{$this->i}\" type=\"checkbox\" class=\"grid_select checkbox_input\" onclick=\"gridSelectAll(this)\"/></th>";
            }
            if (is_array($this->fields)) {
                foreach ($this->fields as $name => $value) {
                    $key = $name;
                    if (strstr($name, 'lll')) {
                        $name_parts = explode('lll', $name);
                        $name = $name_parts[0];
                    }
                    if ($this->inset_id > 0) {
                        if ($value['name'] == $this->inset_id_field) {
                            continue;
                        }
                        if (strstr($this->inset_id_field, '.')) {
                            $inset_field_parts = explode('.', $this->inset_id_field);
                            if ($value['subtable'] == $inset_field_parts[0] && (in_array($inset_field_parts[1], $value['subtable_fields']) || $inset_field_parts[1] == 'id')) {
                                continue;
                            }
                        }
                    }
                    if ($value['is_op'] && !$value['run_in_sql']) {
                        if ($CFG->pm_editor) {
                            $method_name = Form::peLabel($value['method_id'], 'aggregate');
                        }
                        $HTML .= "<th>" . $value['header_caption'] . $method_name . '</th>';
                        continue;
                    } elseif ($value['is_form']) {
                        if ($CFG->pm_editor) {
                            $method_name = Form::peLabel($value['method_id'], 'inlineForm');
                        }
                        if ($value['header_caption']) {
                            $HTML .= "<th class=\"multiple_input\">" . $value['header_caption'] . $method_name . '</th>';
                        }
                        continue;
                    }
                    if ($CFG->pm_editor) {
                        $method_name = !$value['run_in_sql'] ? Form::peLabel($value['method_id'], 'field') : Form::peLabel($value['method_id'], 'aggregate');
                    }
                    if ($value['filter']) {
                        $order_asc = $this->order_asc ? false : true;
                        if ($this->order_by == $name) {
                            $dir_img = $this->order_asc ? $CFG->up : $CFG->down;
                        } else {
                            $dir_img = false;
                        }
                        $filter_results = $_REQUEST['form_filters' . $this->i];
                        $HTML .= "<th>" . Link::url($CFG->url, $value['header_caption'] . $dir_img, false, array('filter' . $this->i => $name, 'order_by' . $this->i => $this->order_by, 'order_asc' . $this->i => $order_asc, 'is_tab' => $this->is_tab, 'inset_id' => $this->inset_id, 'inset_id_field' => $this->inset_id_field, 'inset_i' => $this->inset_i, 'form_filters' . $this->i => $filter_results, 'search_fields' . $this->i => $_REQUEST['search_fields' . $this->i]), false, false, $this->inset_i > 0 ? 'inset_area_' . $this->inset_i : 'content') . $method_name . "</th>";
                    } else {
                        $HTML .= "<th>" . $value['header_caption'] . $method_name . '</th>';
                    }
                }
            }
            $HTML .= $this->show_buttons ? "<th>&nbsp;</th>" : '';
            $HTML .= '</tr>';
            if (is_array($data)) {
                $alt = false;
                foreach ($data as $row) {
                    $alt = $alt ? false : 'alt';
                    if ($this->alert_condition1) {
                        $condition = String::doFormulaReplacements($this->alert_condition1, $row, 1);
                        $alert_class1 = eval("if ({$condition}) { return 1;} else { return 0;}") ? 'alert1' : '';
                    }
                    if ($this->alert_condition2) {
                        $condition = String::doFormulaReplacements($this->alert_condition2, $row, 1);
                        $alert_class2 = eval("if ({$condition}) { return 1;} else { return 0;}") ? 'alert2' : '';
                    }
                    $HTML .= '<tr class="' . $alt . ' ' . $alert_class1 . ' ' . $alert_class2 . '">';
                    if (!is_array($this->fields)) {
                        continue;
                    }
                    if ($CFG->backstage_mode && !$this->links_out && $this->show_buttons && $CFG->is_ctrl_panel != 'Y') {
                        $HTML .= "<td><label for=\"checkbox{$row['id']}\"/><input id=\"checkbox{$row['id']}\" type=\"checkbox\" value=\"{$row['id']}\" class=\"grid_select checkbox_input\"/></td>";
                    }
                    foreach ($this->fields as $name => $properties) {
                        $key = $name;
                        if (strstr($name, 'lll')) {
                            $name_parts = explode('lll', $name);
                            $name = $name_parts[0];
                        }
                        if ($this->inset_id > 0) {
                            if ($properties['name'] == $this->inset_id_field) {
                                continue;
                            }
                            if (strstr($this->inset_id_field, '.')) {
                                $inset_field_parts = explode('.', $this->inset_id_field);
                                if ($properties['subtable'] == $inset_field_parts[0] && (in_array($inset_field_parts[1], $properties['subtable_fields']) || $inset_field_parts[1] == 'id')) {
                                    continue;
                                }
                            }
                        }
                        $value = $row[$key];
                        $link_id = $row[$name . '_id'] ? $row[$name . '_id'] : $value;
                        $class = $properties['class'] ? "class=\"{$properties['class']}\"" : '';
                        $HTML .= "<td {$class}>";
                        if (!empty($properties['is_media'])) {
                            reset($CFG->image_sizes);
                            $m_values = explode('|||', $value);
                            $m_size = !empty($properties['media_size']) ? $properties['media_size'] : key($CFG->image_sizes);
                            $m_limit = !empty($properties['media_amount']) ? $properties['media_amount'] : 1;
                            $HTML .= Gallery::multiple($properties['subtable'], $row['id'], $properties['name'], $properties['media_size'], 0, false, $properties['media_amount'], false, false, true);
                        } elseif ($properties['is_op'] && !$properties['run_in_sql']) {
                            $value1 = number_format(self::doOperation($key, $properties, $row), 2);
                            if (is_array($page_total)) {
                                if (array_key_exists($name, $page_total)) {
                                    $page_total[$key] += $value1;
                                }
                            }
                            if (is_array($page_avg)) {
                                if (array_key_exists($name, $page_avg)) {
                                    $page_avg[$key][] = $value1;
                                }
                            }
                            $HTML .= $value1;
                        } elseif ($properties['is_form']) {
                            if (!$properties['header_caption']) {
                                continue;
                            }
                            $HTML .= '<div>';
                            if (!$ref) {
                                $ref = new ReflectionClass('Form');
                                if (is_array($properties['inputs_array'])) {
                                    foreach ($properties['inputs_array'] as $method => $args) {
                                        $method_parts = explode('|', $method);
                                        $method1 = $method_parts[0];
                                        $params = $ref->getMethod($method1)->getParameters();
                                        if (is_array($params)) {
                                            $i = 0;
                                            foreach ($params as $param) {
                                                $param_name = $param->getName();
                                                if ($param_name == 'value') {
                                                    $i_methods[$method]['value'] = $i;
                                                } elseif ($param_name == 'static') {
                                                    $i_methods[$method]['static'] = $i;
                                                } elseif ($param_name == 'j') {
                                                    $i_methods[$method]['j'] = $i;
                                                } elseif ($param_name == 'checked') {
                                                    $i_methods[$method]['checked'] = $i;
                                                } elseif ($param_name == 'grid_input') {
                                                    $i_methods[$method]['grid_input'] = $i;
                                                } elseif ($param_name == 'is_current_timestamp') {
                                                    $i_methods[$method]['is_current_timestamp'] = $i;
                                                }
                                                $i++;
                                            }
                                        }
                                    }
                                }
                            }
                            if (!empty($properties['insert_new_record_when'])) {
                                $properties['insert_new_record_when'] = String::replaceConditionals('(' . $properties['insert_new_record_when'] . ')', $row, $properties['f_id_field']);
                                $result = eval("if ({$properties['insert_new_record_when']}) { return 0;} else { return 1;}");
                            }
                            $i_table = !empty($properties['table']) ? $properties['table'] : $this->table;
                            $i_f_id = $properties['f_id'] ? $row[str_replace('[', '', str_replace(']', '', $properties['f_id']))] : $row['id'];
                            if (!$result) {
                                $i_row = DB::getRecord($i_table, 0, $row['id'], 1, $properties['f_id_field'], $properties['order_by'], $properties['order_asc']);
                            } else {
                                $i_row = false;
                            }
                            $HTML .= '
							<input type="hidden" name="iform_table' . $this->i . '[' . $row['id'] . ']" value="' . $i_table . '" />
							<input type="hidden" name="iform_id' . $this->i . '[' . $row['id'] . ']" value="' . $i_row['id'] . '" />';
                            if ($i_row) {
                                $HTML .= '<input type="hidden" name="iform_action' . $this->i . '[' . $row['id'] . ']" value="edit" />';
                            } else {
                                $HTML .= '<input type="hidden" name="iform_action' . $this->i . '[' . $row['id'] . ']" value="new" />';
                            }
                            if (is_array($properties['inputs_array'])) {
                                foreach ($properties['inputs_array'] as $method => $args) {
                                    $method_parts = explode('|', $method);
                                    $method1 = $method_parts[0];
                                    $CFG->method_id = $args['pm_method_id'];
                                    unset($args['pm_method_id']);
                                    unset($args['show_total']);
                                    $args1 = $args;
                                    $args = array_values($args);
                                    $i_value = $i_methods[$method]['value'];
                                    $i_checked = $i_methods[$method]['checked'];
                                    $i_static = $i_methods[$method]['static'];
                                    $i_j = $i_methods[$method]['j'];
                                    $i_is_current_timestamp = $i_methods[$method]['is_current_timestamp'];
                                    $input_name = $args[0];
                                    $args[$i_static] = 1;
                                    $args[$i_j] = $input_name;
                                    $args[0] = $row['id'];
                                    if ($method1 == 'textInput') {
                                        $args[13] = '';
                                        ksort($args);
                                    }
                                    if ($method1 == 'hiddenInput') {
                                        $args[8] = '';
                                        $args[$i_is_current_timestamp] = $args1['is_current_timestamp'];
                                        ksort($args);
                                    }
                                    if ($args1['show_total']) {
                                        $totals[$input_name][] = $row[$input_name];
                                    }
                                    if ($method1 == 'checkBox') {
                                        $args[$i_checked] = $i_row[$input_name];
                                    } else {
                                        $args[$i_value] = $i_row[$input_name];
                                    }
                                    if (!$class_instance) {
                                        $CFG->form_output_started = true;
                                        $class_instance = $ref->newInstanceArgs(array('grid_form_' . $this->table . $this->i));
                                    }
                                    $method_instance = $ref->getMethod($method1);
                                    $HTML .= '<div class="col" id="' . $properties['method_id'] . '">' . $method_instance->invokeArgs($class_instance, $args) . '</div>';
                                }
                            }
                            if ($class_instance) {
                                $CFG->o_method_suppress = true;
                                $method_instance = $ref->getMethod('hiddenInput');
                                $HTML .= $method_instance->invokeArgs($class_instance, array($row['id'], 0, $i_f_id, false, false, false, 1, $properties['f_id_field']));
                                $CFG->o_method_suppress = false;
                            }
                            $HTML .= '<div class="clear"></div>';
                            $HTML .= '</div>';
                        } else {
                            $value = self::detectData($key, $value, $fields, $foreign_dates);
                            if (!empty($properties['link_url'])) {
                                $action = $CFG->backstage_mode ? '&action=record' : '';
                                $value = str_replace('|||', ' ', $value);
                                if (!empty($value)) {
                                    $HTML .= Link::url($properties['link_url'], $value, "id={$link_id}&is_tab={$properties['link_is_tab']}{$action}", false, false, 'content');
                                }
                            } else {
                                $HTML .= str_ireplace('|||', ' ', $value);
                            }
                            if (is_array($page_total)) {
                                if (array_key_exists($name, $page_total)) {
                                    $page_total[$key] += $value;
                                }
                            }
                            if (is_array($page_avg)) {
                                if (array_key_exists($name, $page_avg)) {
                                    $page_avg[$key][] = $value;
                                }
                            }
                        }
                        $HTML .= "</td>";
                    }
                    if ($this->show_buttons) {
                        $HTML .= '<td><nobr>';
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 0) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=record&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'view', false, false, false, false, $CFG->view_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1) {
                            $HTML .= Link::url($this->link_url, false, 'id=' . $row['id'] . '&action=form&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'edit', false, false, false, false, $CFG->edit_hover_caption) . ' ';
                        }
                        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1 && !$this->links_out) {
                            $HTML .= '<a href="#" title="' . $CFG->delete_hover_caption . '" onclick="gridDelete(' . $row['id'] . ',\'' . $this->table . '\',this)" class="delete"></a></nobr></td>';
                        }
                    }
                    $HTML .= '</tr>';
                }
            } else {
                $HTML .= '<tr><td colspan="' . (count($this->fields) + 2) . '">' . $CFG->grid_no_results . '</td></tr>';
            }
            if ($page_total || $page_avg) {
                $HTML .= '<tr>';
                if ($this->show_buttons) {
                    $HTML .= '<td></td>';
                }
                foreach ($this->fields as $name => $properties) {
                    if ($page_total[$name]) {
                        $subtotal = $page_total[$name];
                        $subtotal = stristr($fields[$name]['Type'], 'double') ? number_format($subtotal, 2) : $subtotal;
                        $subtotals[$name] = $subtotal;
                    } else {
                        $subtotal = false;
                    }
                    if ($page_avg[$name]) {
                        $subavg = array_sum($page_avg[$name]) / count($page_avg[$name]);
                        $subavg = stristr($fields[$name]['Type'], 'double') ? number_format($subavg, 2) : $subavg;
                        $subavgs[$name] = $subavg;
                    } else {
                        $subavg = false;
                    }
                }
                $subtotals = $subtotals ? $subtotals : array();
                $subavgs = $subavgs ? $subavgs : array();
                $subs = array_merge($subtotals, $subavgs);
                foreach ($this->fields as $name => $properties) {
                    $sub = $subs[$name] ? $subs[$name] : false;
                    $HTML .= '<td class="subtotal">' . (is_numeric($sub) ? number_format($sub, 2) : $sub) . '</td>';
                }
                if ($this->show_buttons) {
                    $HTML .= '<td class="subtotal"><em>' . ($page_total ? $CFG->subtotal_label : '') . ($page_total && $page_avg ? '/' : '') . ($page_avg ? $CFG->subavg_label : '') . '</em></td>';
                }
                $HTML .= '</tr>';
            }
            if ($grand_total || $grand_avg) {
                $HTML .= '<tr>';
                if ($this->show_buttons) {
                    $HTML .= '<td class="total"></td>';
                }
                foreach ($this->fields as $name => $properties) {
                    if ($properties['is_op'] && !$properties['run_in_sql']) {
                        continue;
                    }
                    if (is_array($grand_total)) {
                        if (array_key_exists($name, $grand_total)) {
                            $total = array_key_exists($name, $grand_total) ? number_format(DB::getTotal($properties, $this->table), 2) : false;
                            $totals[$name] = $total;
                        }
                    }
                    if (is_array($grand_avg)) {
                        if (array_key_exists($name, $grand_avg)) {
                            //$avg = (array_key_exists($name,$grand_avg)) ? number_format(DB::get($this->table,array($this->table.'.'.$name),$page,$this->rows_per_page,$this->order_by,$this->order_asc,0,$this->filter_results,$this->inset_id,$this->inset_id_field,0,1),2) : false;
                            $avg = array_key_exists($name, $grand_avg) ? number_format(DB::getAverage($properties, $this->table), 2) : false;
                            $totals[$name] = $avg;
                        }
                    }
                }
                foreach ($this->fields as $name => $properties) {
                    if ($properties['is_op'] && !$properties['run_in_sql']) {
                        /*
                        $formula = $properties['formula'];
                        foreach ($totals as $o_name => $o_value) {
                        	$formula = str_replace($o_name,str_replace(',','',$o_value),$formula);
                        }
                        $total = eval("return $formula ;");
                        */
                        $total = false;
                    } else {
                        if ($totals[$name]) {
                            $total = $totals[$name];
                        } else {
                            $total = false;
                        }
                    }
                    $HTML .= '<td class="total">' . (is_numeric($total) ? number_format($total, 2) : $total) . '</td>';
                }
                if ($this->show_buttons) {
                    $HTML .= '<td class="total"><em>' . ($grand_total ? $CFG->total_label : '') . ($grand_total && $grand_avg ? '/' : '') . ($grand_avg ? $CFG->avg_label : '') . '</em></td>';
                }
                $HTML .= '</tr>';
            }
            $HTML .= '</table>';
        }
        $pagination = Grid::pagination($page, $total_rows);
        if ($this->grid_label) {
            if ($CFG->pm_editor) {
                $method_name = Form::peLabel($this->grid_label['method_id'], 'gridLabel');
            }
            $grid_label = $this->grid_label['text'] . ' ' . $method_name;
        } else {
            $grid_label = Ops::getPageTitle();
        }
        Grid::show_filters();
        Grid::show_errors();
        $amount = $total_rows > 0 ? '(' . $total_rows . ')' : false;
        if (!($this->inset_id > 0 || $CFG->is_form_inset)) {
            echo '
			<div class="area full_box" id="grid_' . $this->i . '">
				<h2>' . $grid_label . ' ' . $amount . '</h2>
				<div class="box_bar"></div>
				<div class="box_tl"></div>
				<div class="box_tr"></div>
				<div class="box_bl"></div>
				<div class="box_br"></div>
				<div class="t_shadow"></div>
				<div class="r_shadow"></div>
				<div class="b_shadow"></div>
				<div class="l_shadow"></div>
				<div class="box_b"></div>
				<div class="grid_buttons">
				' . $pagination . '';
            if (is_array($this->modes)) {
                if (count($this->modes) > 1) {
                    echo '<div class="modes">';
                    foreach ($this->modes as $mode => $enabled) {
                        $class1 = $mode == $this->mode ? 'active_view' : false;
                        if ($mode == 'table') {
                            $class = 'switch_table';
                            $caption = $CFG->switch_to_table;
                        } elseif ($mode == 'list') {
                            $class = 'switch_list';
                            $label = $CFG->switch_to_list;
                        } elseif ($mode == 'graph') {
                            $class = 'switch_graph';
                            $label = $CFG->switch_to_graph;
                        } elseif ($mode == 'graph_line') {
                            $class = 'switch_graph_line';
                            $label = $CFG->switch_to_graph_line;
                        } elseif ($mode == 'graph_pie') {
                            $class = 'switch_graph_pie';
                            $label = $CFG->switch_to_graph_pie;
                        }
                        echo Link::url($CFG->url, false, false, array('page' . $this->i => $page, 'p_bypass' . $this->i => 1, 'mode' . $this->i => $mode), true, 'content', $class . ' ' . $class1, false, false, false, false, $label) . ' ';
                    }
                    echo '</div>';
                }
            }
            if (!$this->links_out && $this->show_buttons && $CFG->is_ctrl_panel != 'Y') {
                echo '<div class="button before"></div>';
                if (is_array($this->fields)) {
                    foreach ($this->fields as $properties) {
                        if ($properties['is_form']) {
                            $i_name = !$properties['button_submit_all'] ? $properties['name'] : 'all';
                            echo '<a href="#" onclick="gridSubmitForm(\'' . $this->table . $this->i . '\')" class="button"><div class="save"></div>' . $properties['save_button_caption'] . '</a>';
                            if ($properties['button_submit_all']) {
                                break;
                            }
                        }
                    }
                }
                if (array_key_exists('is_active', $fields)) {
                    echo '<a class="button" href="#" onclick="gridSetActive(\'' . $this->table . '\',1)">' . $CFG->grid_activate_button . '</a>';
                    echo '<a class="button" href="#" onclick="gridSetActive(\'' . $this->table . '\')">' . $CFG->grid_deactivate_button . '</a>';
                }
                echo Link::url($this->link_url, '<div class="add_new"></div>' . $CFG->add_new_caption, '&action=form&is_tab=' . $this->is_tab, false, false, $this->target_elem_id, 'button') . '<a class="button last" href="#" onclick="gridDeleteSelection(\'' . $this->table . '\')"><div class="delete"></div> ' . $CFG->delete_button_label . '</a>';
                echo '<div class="button after"></div>';
            }
            echo '
				</div>
				<div class="contain">';
        }
        $HTML .= '
		<script type="text/javascript">
			$(document).ready(function() {
				$("#grid_' . $this->i . '").find("th").mouseover(function() {
					gridHighlightTH(this);
				});
				$("#grid_' . $this->i . '").find("th").mouseout(function() {
					gridUnHighlightTH(this);
				});
				$("#grid_' . $this->i . '").find("td").mouseover(function() {
					gridHighlightTD(this);
				});
				$("#grid_' . $this->i . '").find("td").mouseout(function() {
					gridUnHighlightTD(this);
				});
			';
        if (User::permission(0, 0, $this->link_url, false, $this->is_tab) < 1) {
            $HTML .= '
				$("input").attr("disabled","disabled");
				$("select").attr("disabled","disabled");
			';
        }
        $HTML .= '
			});
		</script>';
        echo $HTML;
        if ($this->rows_per_page > 30) {
            echo $pagination;
        }
        if ($CFG->backstage_mode && User::permission(0, 0, $this->link_url, false, $this->is_tab) > 1 && $this->inset_id === false) {
            echo "</form>";
        }
        if (!($this->inset_id > 0 || $CFG->is_form_inset)) {
            echo '</div></div>';
        }
    }
Ejemplo n.º 6
0
    $Ops = new Ops($Operations);
    if ($Ops->save() !== false) {
        die('ok:' . serviceref($_REQUEST['content']));
    } else {
        die('Please fix errors!');
    }
    exit;
    // do not show the interface
}
$buttons = "";
if (isset($_REQUEST['edit'])) {
    $edit = true;
} else {
    $edit = false;
}
$Ops = new Ops();
writeHead("<TITLE>Ops - Meterkast - ADL Prototype</TITLE>" . ($edit ? '<SCRIPT type="text/javascript" src="js/edit.js"></SCRIPT>' : '<SCRIPT type="text/javascript" src="js/navigate.js"></SCRIPT>') . "\n");
if ($edit) {
    echo '<FORM name="editForm" action="' . $_SERVER['PHP_SELF'] . '" method="POST" class="Edit">';
}
?>
<H1>Ops</H1>
    <DIV class="Floater Operations">
      <DIV class="FloaterHeader">Operations</DIV>
      <DIV class="FloaterContent"><?php 
$Operations = $Ops->get_Operations();
echo '
          <UL>';
foreach ($Operations as $i0 => $idv0) {
    $v0 = $idv0;
    echo '