示例#1
0
 public function reg_data()
 {
     $_label = array('05-01', '05-02', '05-03', '05-04', '05-05', '05-06', '05-07', '05-08', '05-09', '05-10', '05-11', '05-12', '05-13', '05-14', '05-15');
     $_value = array(1235, 1125, 1323, 1389, 1256, 1568, 1383, 1677, 1953, 1798, 2089, 2215, 1738, 2189, 2315);
     $_max_value = 2500;
     $this->load->library('OFC_Chart');
     $title = new OFC_Elements_Title("日注册用户数(人)");
     //创建图表类型对象
     $element = new OFC_Charts_Bar_Glass();
     //设置图标值
     $element->set_values($_value);
     //$element->set_width( 2 );
     //$element->set_dot_style(array('type'=>"solid-dot",'dot-size'=>5,'halo-size'=>1,'colour'=>'#3D5C56'));
     //设置动画
     $element->set_on_show(array('type' => "pop-up", 'cascade' => 0.8, 'delay' => 0.1));
     $element->set_colour("#009829");
     //创建图表对象
     $chart = new OFC_Chart();
     $chart->set_title($title);
     //图表类型添加到图表
     $chart->add_element($element);
     //x轴
     $x_axis = new OFC_Elements_Axis_X();
     $x_axis->set_labels(array('labels' => $_label));
     $x_axis->set_steps(1);
     $chart->set_x_axis($x_axis);
     //y轴
     $y_axis = new OFC_Elements_Axis_Y();
     $y_axis->set_range(0, $_max_value, $_max_value / 10);
     $chart->set_y_axis($y_axis);
     //x 脚标
     $x_legend = new OFC_Elements_Legend_X('日期');
     $x_legend->set_style('{font-size: 20px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $chart->set_bg_colour('#ffffff');
     echo $chart->toPrettyString();
 }
 public function chartDataAction()
 {
     // Disable layout and viewrenderer
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     // Get params
     $type = $this->_getParam('type');
     $start = $this->_getParam('start');
     $offset = $this->_getParam('offset', 0);
     $mode = $this->_getParam('mode');
     $chunk = $this->_getParam('chunk');
     $period = $this->_getParam('period');
     $periodCount = $this->_getParam('periodCount', 1);
     //$end = $this->_getParam('end');
     // Validate chunk/period
     if (!$chunk || !in_array($chunk, $this->_periods)) {
         $chunk = Zend_Date::DAY;
     }
     if (!$period || !in_array($period, $this->_periods)) {
         $period = Zend_Date::MONTH;
     }
     if (array_search($chunk, $this->_periods) >= array_search($period, $this->_periods)) {
         die('whoops');
         return;
     }
     // Validate start
     if ($start && !is_numeric($start)) {
         $start = strtotime($start);
     }
     if (!$start) {
         $start = time();
     }
     // Fixes issues with month view
     Zend_Date::setOptions(array('extend_month' => true));
     // Get timezone
     $timezone = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_locale_timezone', 'GMT');
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer && $viewer->getIdentity() && !empty($viewer->timezone)) {
         $timezone = $viewer->timezone;
     }
     // Make start fit to period?
     $startObject = new Zend_Date($start);
     $startObject->setTimezone($timezone);
     $partMaps = $this->_periodMap[$period];
     foreach ($partMaps as $partType => $partValue) {
         $startObject->set($partValue, $partType);
     }
     // Do offset
     if ($offset != 0) {
         $startObject->add($offset, $period);
     }
     // Get end time
     $endObject = new Zend_Date($startObject->getTimestamp());
     $endObject->setTimezone($timezone);
     $endObject->add($periodCount, $period);
     $endObject->sub(1, Zend_Date::SECOND);
     // Subtract one second
     // Get data
     $statsTable = Engine_Api::_()->getDbtable('statistics', 'core');
     $statsSelect = $statsTable->select()->where('type = ?', $type)->where('date >= ?', gmdate('Y-m-d H:i:s', $startObject->getTimestamp()))->where('date < ?', gmdate('Y-m-d H:i:s', $endObject->getTimestamp()))->order('date ASC');
     $rawData = $statsTable->fetchAll($statsSelect);
     // Now create data structure
     $currentObject = clone $startObject;
     $nextObject = clone $startObject;
     $data = array();
     $dataLabels = array();
     $cumulative = 0;
     $previous = 0;
     do {
         $nextObject->add(1, $chunk);
         $currentObjectTimestamp = $currentObject->getTimestamp();
         $nextObjectTimestamp = $nextObject->getTimestamp();
         $data[$currentObjectTimestamp] = $cumulative;
         // Get everything that matches
         $currentPeriodCount = 0;
         foreach ($rawData as $rawDatum) {
             $rawDatumDate = strtotime($rawDatum->date);
             if ($rawDatumDate >= $currentObjectTimestamp && $rawDatumDate < $nextObjectTimestamp) {
                 $currentPeriodCount += $rawDatum->value;
             }
         }
         // Now do stuff with it
         switch ($mode) {
             default:
             case 'normal':
                 $data[$currentObjectTimestamp] = $currentPeriodCount;
                 break;
             case 'cumulative':
                 $cumulative += $currentPeriodCount;
                 $data[$currentObjectTimestamp] = $cumulative;
                 break;
             case 'delta':
                 $data[$currentObjectTimestamp] = $currentPeriodCount - $previous;
                 $previous = $currentPeriodCount;
                 break;
         }
         $currentObject->add(1, $chunk);
     } while ($currentObject->getTimestamp() < $endObject->getTimestamp());
     // Reprocess label
     $labelStrings = array();
     $labelDate = new Zend_Date();
     foreach ($data as $key => $value) {
         $labelDate->set($key);
         $labelStrings[] = $this->view->locale()->toDate($labelDate, array('size' => 'short'));
         //date('D M d Y', $key);
     }
     // Let's expand them by 1.1 just for some nice spacing
     $minVal = min($data);
     $maxVal = max($data);
     $minVal = floor($minVal * ($minVal < 0 ? 1.1 : 1 / 1.1) / 10) * 10;
     $maxVal = ceil($maxVal * ($maxVal > 0 ? 1.1 : 1 / 1.1) / 10) * 10;
     // Remove some labels if there are too many
     $xlabelsteps = 1;
     if (count($data) > 10) {
         $xlabelsteps = ceil(count($data) / 10);
     }
     // Remove some grid lines if there are too many
     $xsteps = 1;
     if (count($data) > 100) {
         $xsteps = ceil(count($data) / 100);
     }
     // Create base chart
     require_once 'OFC/OFC_Chart.php';
     // Make x axis labels
     $x_axis_labels = new OFC_Elements_Axis_X_Label_Set();
     $x_axis_labels->set_steps($xlabelsteps);
     $x_axis_labels->set_labels($labelStrings);
     // Make x axis
     $labels = new OFC_Elements_Axis_X();
     $labels->set_labels($x_axis_labels);
     $labels->set_colour("#416b86");
     $labels->set_grid_colour("#dddddd");
     $labels->set_steps($xsteps);
     // Make y axis
     $yaxis = new OFC_Elements_Axis_Y();
     $yaxis->set_range($minVal, $maxVal);
     $yaxis->set_colour("#416b86");
     $yaxis->set_grid_colour("#dddddd");
     // Make data
     $graph = new OFC_Charts_Line();
     $graph->set_values(array_values($data));
     $graph->set_colour("#5ba1cd");
     // Make title
     $locale = Zend_Registry::get('Locale');
     $translate = Zend_Registry::get('Zend_Translate');
     $titleStr = $translate->_('_CORE_ADMIN_STATS_' . strtoupper(trim(preg_replace('/[^a-zA-Z0-9]+/', '_', $type), '_')));
     $title = new OFC_Elements_Title($titleStr . ': ' . $this->view->locale()->toDateTime($startObject) . ' to ' . $this->view->locale()->toDateTime($endObject));
     $title->set_style("{font-size: 14px;font-weight: bold;margin-bottom: 10px; color: #777777;}");
     // Make full chart
     $chart = new OFC_Chart();
     $chart->set_bg_colour('#ffffff');
     $chart->set_x_axis($labels);
     $chart->add_y_axis($yaxis);
     $chart->add_element($graph);
     $chart->set_title($title);
     // Send
     $this->getResponse()->setBody($chart->toPrettyString());
 }
示例#3
0
文件: line-dot.php 项目: RA2WP/RA2WP
    $data_2[] = sin($i) * 1.9 + 10;
    $data_3[] = sin($i) * 1.9 + 4;
    // just show to two decimal places
    // in our labels:
    //$labels[] = number_format($tmp,2);
}
$title = new OFC_Elements_Title(date("D M d Y"));
$line_1 = new OFC_Charts_Line_Dot();
$line_1->set_values($data_1);
$line_1->set_halo_size(0);
$line_1->set_width(2);
$line_1->set_dot_size(4);
$line_2 = new OFC_Charts_Line_Dot();
$line_2->set_values($data_2);
$line_2->set_halo_size(1);
$line_2->set_width(1);
$line_2->set_dot_size(4);
$line_3 = new OFC_Charts_Line_Dot();
$line_3->set_values($data_3);
$line_3->set_halo_size(1);
$line_3->set_width(6);
$line_3->set_dot_size(4);
$y = new OFC_Elements_Axis_Y();
$y->set_range(0, 15, 5);
$chart = new OFC_Chart();
$chart->set_title($title);
$chart->add_element($line_1);
$chart->add_element($line_2);
$chart->add_element($line_3);
$chart->set_y_axis($y);
echo $chart->toPrettyString();
示例#4
0
for ($i = 0; $i < 6.2; $i += 0.2) {
    $tmp = sin($i) * 1.9;
    $data[] = $tmp;
}
require_once 'OFC/OFC_Chart.php';
$chart = new OFC_Chart();
$chart->set_title(new OFC_Elements_Title('Area Chart'));
//
// Make our area chart:
//
$area = new OFC_Charts_Area_Hollow();
// set the circle line width:
$area->set_width(1);
$area->set_values($data);
// add the area object to the chart:
$chart->add_element($area);
$y_axis = new OFC_Elements_Axis_Y();
$y_axis->set_range(-2, 2, 2);
$y_axis->labels = null;
$y_axis->set_offset(false);
$x_axis = new OFC_Elements_Axis_X();
$x_axis->labels = $data;
$x_axis->set_steps(2);
$x_labels = new OFC_Elements_Axis_X_Label_Set();
$x_labels->set_steps(4);
$x_labels->set_vertical();
// Add the X Axis Labels to the X Axis
$x_axis->set_labels($x_labels);
$chart->add_y_axis($y_axis);
$chart->x_axis = $x_axis;
echo $chart->toPrettyString();
示例#5
0
 public function draw_category_chart($ref_rec, $gb_captions)
 {
     $f = $this->init_module(Libs_OpenFlashChart::module_name());
     $title = new OFC_Elements_Title($ref_rec);
     $f->set_title($title);
     $labels = array();
     foreach ($gb_captions as $cap) {
         $labels[] = $cap['name'];
     }
     $x_ax = new OFC_Elements_Axis_X();
     $x_ax->set_labels_from_array($labels);
     $f->set_x_axis($x_ax);
     $max = 5;
     $color = 0;
     foreach ($this->ref_records as $q => $r) {
         $results = call_user_func($this->display_cell_callback, $r);
         $title2 = strip_tags(call_user_func($this->ref_record_display_callback, $r, true));
         $bar = new OFC_Charts_Line();
         $bar->set_colour(self::$colours[$color % count(self::$colours)]);
         $color++;
         $bar->set_key($title2, 10);
         $arr = array();
         foreach ($results as $v) {
             if ($ref_rec) {
                 if (is_array($v[$ref_rec])) {
                     $v[$ref_rec] = array_pop($v[$ref_rec]);
                 }
                 $val = (double) strip_tags($v[$ref_rec]);
             } else {
                 if (is_array($v)) {
                     $v = array_pop($v);
                 }
                 $val = (double) strip_tags($v);
             }
             $arr[] = $val;
             if ($max < $val) {
                 $max = $val;
             }
         }
         $bar->set_values($arr);
         $f->add_element($bar);
     }
     $y_ax = new OFC_Elements_Axis_Y();
     $y_ax->set_range(0, $max);
     $y_ax->set_steps($max / 10);
     $f->set_y_axis($y_ax);
     $f->set_width(950);
     $f->set_height(400);
     $this->display_module($f);
 }
示例#6
0
    $data_1[] = rand(1, 6);
    $data_2[] = rand(7, 13);
    $data_3[] = rand(14, 19);
}
$line_dot = new OFC_Charts_Line_Dot();
$line_dot->set_width(4);
$line_dot->set_colour('#DFC329');
$line_dot->set_dot_size(5);
$line_dot->set_values($data_1);
$line_hollow = new OFC_Charts_Line_Hollow();
$line_hollow->set_width(1);
$line_hollow->set_colour('#6363AC');
$line_hollow->set_dot_size(5);
$line_hollow->set_values($data_2);
$line = new OFC_Charts_Line();
$line->set_width(1);
$line->set_colour('#5E4725');
$line->set_dot_size(5);
$line->set_values($data_3);
$y = new OFC_Elements_Axis_Y();
$y->set_range(0, 20, 5);
$chart = new OFC_Chart();
$chart->set_title(new OFC_Elements_Title('Three lines example'));
$chart->set_y_axis($y);
//
// here we add our data sets to the chart:
//
$chart->add_element($line_dot);
$chart->add_element($line_hollow);
$chart->add_element($line);
echo $chart->toPrettyString();
示例#7
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
require_once 'OFC/OFC_Chart.php';
$chart = new OFC_Chart();
$title = new OFC_Elements_Title(date("D M d Y"));
$chart->set_title($title);
$scatter = new OFC_Charts_Scatter('#FFD600', 10);
$scatter->set_values(array(new OFC_Charts_Scatter_Value(0, 0)));
$chart->add_element($scatter);
//
// plot a circle
//
$s2 = new OFC_Charts_Scatter('#D600FF', 3);
$v = array();
for ($i = 0; $i < 360; $i += 5) {
    $v[] = new OFC_Charts_Scatter_Value(number_format(sin(deg2rad($i)), 2, '.', ''), number_format(cos(deg2rad($i)), 2, '.', ''));
}
$s2->set_values($v);
$chart->add_element($s2);
$x = new OFC_Elements_Axis_X();
$x->set_range(-2, 2);
$chart->set_x_axis($x);
$y = new OFC_Elements_Axis_Y();
$y->set_range(-2, 2);
$chart->add_y_axis($y);
echo $chart->toPrettyString();
示例#8
0
<?php

require_once(OFC_LIBRARY_PATH . '/lib/OFC/OFC_Chart.php');

$title = new OFC_Elements_Title( date("D M d Y") );

$bar_stack = new OFC_Charts_Bar_Stack();
$bar_stack->append_stack( array( 2.5, 5 ) );
$bar_stack->append_stack( array( 7.5 ) );
$bar_stack->append_stack( array( 5, new OFC_Charts_Bar_Stack_Value(5, '#ff0000') ) );
$bar_stack->append_stack( array( 2, 2, 2, 2, new OFC_Charts_Bar_Stack_Value(2, '#ff00ff') ) );

$y = new OFC_Elements_Axis_Y();
$y->set_range( 0, 14, 7 );

$x = new OFC_Elements_Axis_X();
$x->set_labels( array( 'a', 'b', 'c', 'd' ) );

$chart = new OFC_Chart();
$chart->set_title( $title );
$chart->add_element( $bar_stack );
$chart->set_x_axis( $x );
$chart->add_y_axis( $y );

echo $chart->toPrettyString();
示例#9
0
function render_chart($options = array())
{
    $genid = array_var($options, 'genid', gen_id());
    $title = array_var($options, 'title', '');
    $width = array_var($options, 'width', 700);
    $height = array_var($options, 'height', 500);
    $type = array_var($options, 'type', 'line');
    $x_range = array_var($options, 'x_range', array());
    $y_range = array_var($options, 'y_range', array());
    $x_labels = array_var($options, 'x_labels', array());
    $y_axis_right = array_var($options, 'y_axis_right');
    $y_values = array_var($options, 'data');
    $shapes = array_var($options, 'shapes', array());
    $label_step = array_var($options, 'label_step', 7);
    $title = new OFC_Elements_Title($title);
    $max = 0;
    $chart_values = array();
    foreach ($y_values as $y_values_array) {
        $data_object = create_chart_data_object($type, $y_values_array);
        $values_data = array_var($y_values_array, 'values', array());
        $max = count($values_data) > $max ? count($values_data) : $max;
        $chart_values[] = $data_object;
    }
    $x_range_start = array_var($x_range, 'start', 0);
    $x_range_end = array_var($x_range, 'end', 10) - $x_range_start > $max ? $max + $x_range_start - 1 : array_var($x_range, 'end', 10);
    $labels = array();
    $coef = floor(count($x_labels) / $label_step);
    if ($coef > 0) {
        $k = 0;
        foreach ($x_labels as $label) {
            $labels[] = $k % $coef == 0 ? $label : "";
            $k++;
        }
    } else {
        $labels = $x_labels;
    }
    $x_axis = new OFC_Elements_Axis_X();
    $x_axis->set_colours(array_var($options, 'x_axis_color', '#87C4FA'), array_var($options, 'x_grid_color', '#D4E8FA'));
    if (array_var($x_range, 'step')) {
        $x_axis->set_range($x_range_start, $x_range_end, array_var($x_range, 'step', 1));
    }
    $x_axis->set_labels_from_array($labels);
    $y_axis = new OFC_Elements_Axis_Y();
    $y_axis->set_colours(array_var($options, 'y_axis_color', '#87C4FA'), array_var($options, 'y_grid_color', '#D4E8FA'));
    if (array_var($y_range, 'step')) {
        $y_axis->set_range(array_var($y_range, 'start', 0), array_var($y_range, 'end', 10), array_var($y_range, 'step', 1));
    }
    $chart = new OFC_Chart();
    $chart->set_title($title);
    foreach ($chart_values as $cv) {
        $chart->add_element($cv);
    }
    $chart->set_x_axis($x_axis);
    $chart->set_y_axis($y_axis);
    $chart->set_bg_colour(array_var($options, 'back_color', '#FFFFFF'));
    if ($y_axis_right) {
        $chart->set_y_axis_right($y_axis);
    }
    foreach ($shapes as $s) {
        $shape = new shape(array_var($s, 'color', '#FA6900'));
        $points = array_var($s, 'points', array());
        foreach ($points as $p) {
            $shape->append_value(new shape_point($p['x'], $p['y']));
        }
        if (array_var($s, 'text')) {
            $shape->set_text(array_var($s, 'text'));
        }
        if (array_var($s, 'alpha')) {
            $shape->set_alpha(array_var($s, 'alpha'));
        }
        $chart->add_element($shape);
    }
    $filename = 'tmp/' . gen_id() . '.json';
    file_put_contents(ROOT . "/{$filename}", $chart->toPrettyString());
    open_flash_chart_object($width, $height, ROOT_URL . "/{$filename}", $genid);
    //	unlink(ROOT . "/$filename");
}
示例#10
0
文件: Ofc.php 项目: Aeryris/grid
    public function deploy()
    {
        $this->checkExportRights();
        if ($this->_filesLocation === null) {
            throw new Bvb_Grid_Exception($this->__("Please set Javascript and Flash file locations using SetFilesLocation()"));
        }
        $grid = array();
        $newData = array();
        $label = array();
        $result = array();
        parent::deploy();
        $data = parent::_buildGrid();
        if (count($data) == 0) {
            $this->_deploymentContent = '';
            return;
        }
        foreach ($data as $value) {
            foreach ($value as $final) {
                $result[$final['field']][] = is_numeric($final['value']) ? $final['value'] : strip_tags($final['value']);
            }
        }
        if (is_string($this->_xLabels) && isset($result[$this->_xLabels])) {
            $this->_xLabels = $result[$this->_xLabels];
        }
        $graph = new OFC_Chart();
        $title = new OFC_Elements_Title($this->_title);
        $title->set_style($this->_style);
        $graph->set_title($title);
        foreach ($this->_chartOptions as $key => $value) {
            $graph->{$key}($value);
        }
        if (count($this->_xLabels) > 0) {
            $x = new OFC_Elements_Axis_X();
            $x_axis_labels = new OFC_Elements_Axis_X_Label_Set();
            foreach ($this->_xAxisOptions as $key => $value) {
                $x_axis_labels->{$key}($value);
            }
            $x_axis_labels->set_labels($this->_xLabels);
            $x->set_labels($x_axis_labels);
            foreach ($this->_xLabelsOptions as $key => $value) {
                $x->{$key}($value);
            }
            $graph->set_x_axis($x);
        }
        if (!empty($this->_xLegendText) && !empty($this->_xLegendStyle)) {
            $x_legend = new OFC_Elements_Legend_X($this->_xLegendText);
            $x_legend->set_style($this->_xLegendStyle);
            $graph->set_x_legend($x_legend);
        }
        $min = 0;
        $max = 0;
        if (count($this->_values) == 0) {
            $this->setValues(key($result));
        }
        foreach ($this->_values as $key => $value) {
            if (is_array($value)) {
                $support = $value;
                sort($support);
                if (reset($support) < $min) {
                    $min = reset($support);
                }
                if (end($support) > $max) {
                    $max = end($support);
                }
                unset($support);
                $options = $this->_chartOptionsValues[$value];
                if (isset($options['chartType'])) {
                    $this->setChartType($options['chartType']);
                }
                $bar = new $this->_type();
                foreach ($options as $key => $prop) {
                    $bar->{$key}($prop);
                }
                $this->_type();
                $pie = array();
                if ($this->_type == 'Pie') {
                    foreach ($value as $key => $title) {
                        $pie[] = array('value' => $title, 'label' => $this->_xLabels[$key]);
                    }
                    $bar->set_values($pie);
                } else {
                    $bar->set_values($value);
                }
                $graph->add_element($bar);
            } elseif (is_string($value) && isset($result[$value])) {
                $options = $this->_chartOptionsValues[$value];
                if (isset($options['chartType'])) {
                    $this->setChartType($options['chartType']);
                }
                $bar = new $this->_type();
                foreach ($options as $key => $prop) {
                    $bar->{$key}($prop);
                }
                $value = array_map(create_function('$item', ' return (float)$item; '), $result[$value]);
                $support = $value;
                sort($support);
                if (reset($support) < $min) {
                    $min = reset($support);
                }
                if (end($support) > $max) {
                    $max = end($support);
                }
                unset($support);
                $pie = array();
                if ($this->_type == 'OFC_Charts_Pie') {
                    foreach ($value as $key => $title) {
                        $pie[] = array('value' => $title, 'label' => $this->_xLabels[$key]);
                    }
                    $bar->set_values($pie);
                } else {
                    $bar->set_values($value);
                }
                $graph->add_element($bar);
            }
        }
        $max = $max * 1.05;
        $y = new OFC_Elements_Axis_Y();
        $y->set_range($min, $max, ceil($max / 4));
        $graph->add_y_axis($y);
        $final = $graph->toPrettyString();
        if (!is_string($this->_chartId)) {
            $this->_chartId = 'chart_' . rand(1, 10000);
        }
        $script = '
        swfobject.embedSWF(
        "' . $this->_filesLocation['flash'] . '", "' . $this->_chartId . '",
        "' . $this->_chartDimensions['x'] . '", "' . $this->_chartDimensions['y'] . '", "9.0.0", "expressInstall.swf",{"id":"' . $this->_chartId . '"},{"z-index":"1","wmode":"transparent"} );

        function open_flash_chart_data(id)
        {
            return JSON.stringify(window[id]);
        }

        function findSWF(movieName) {
          if (navigator.appName.indexOf("Microsoft")!= -1) {
            return window[movieName];
          } else {
            return document[movieName];
          }
        }
        var ' . $this->_chartId . ' = ' . $final . ';';
        $final = '<div id="' . $this->_chartId . '" >
        loading...
        <br/>
        <p>
        Please note that this content requires flash player 9.0.0</br>
        To test for your version of flash, <a href="http://www.bobbyvandersluis.com/swfobject/testsuite_2_1/test_api_getflashplayerversion.html" target="_blank">click here</a>
        </p>
        </div>';
        if (!$this->_multiple) {
            $final = '<div style="width: 100%;text-align: center">' . $final . '</div>';
        }
        $this->getView()->headScript()->appendFile($this->_filesLocation['js']);
        $this->getView()->headScript()->appendFile($this->_filesLocation['json']);
        $this->getView()->headScript()->appendScript($script);
        $this->_deploymentContent = $final;
        return $this;
    }
 /**
  * @Route("/{anno}/{mes}/{assigned_user_id}/{width}/panel_detalle_discovery_metas_in_progress_data.json", name="panel_detalle_discovery_metas_in_progress_data", defaults={"anno"="2013","mes"="01"}, options={"expose"=true})
  */
 public function panelDetalleDiscoveryMetasPorAgenteDataAction($anno, $mes, $assigned_user_id, $width)
 {
     include_once __DIR__ . "/../Util/OFC/OFC_Chart.php";
     $title = new \OFC_Elements_Title('STATUS DE LAS REUNIONES V/S METAS DEL AGENTE ');
     $bar = new \OFC_Charts_Bar_Stack();
     $sql = "SELECT CONCAT(users.user_name,' ',users.first_name,' ', users.last_name) as owner, meetings.assigned_user_id, (SELECT count(*) FROM meetings m WHERE parent_type = 'Accounts' AND m.deleted = 0 AND YEAR(m.date_start) = 2015 AND m.assigned_user_id = meetings.assigned_user_id ) as meetings,(SELECT count(*) FROM meetings m2 INNER JOIN accounts_opportunities ON m2.parent_id = accounts_opportunities.opportunity_id  WHERE parent_type = 'Opportunities' AND 1 AND m2.deleted = 0 AND YEAR(m2.date_start) = " . $anno . " ) as meetings_opportunities FROM meetings INNER JOIN users ON users.id = meetings.assigned_user_id AND meetings.deleted = 0 AND meetings.assigned_user_id = '" . $assigned_user_id . "' GROUP BY assigned_user_id HAVING (meetings + meetings_opportunities) > 0;";
     $stmt = $this->container->get('doctrine')->getManager()->getConnection()->prepare($sql);
     $stmt->execute();
     //Valores
     $valor = 0;
     foreach ($stmt->fetchAll() as $data) {
         $valor = (int) $data['meetings'] + (int) $data['meetings_opportunities'];
         $bar->append_stack(array(new \OFC_Charts_Bar_Stack_Value((int) $data['meetings'], '#ff0000'), new \OFC_Charts_Bar_Stack_Value((int) $data['meetings_opportunities'], '#1240AB')));
     }
     //Metas
     $sql = "SELECT sem_1_c, sem_2_c FROM cammr_metasreuniones INNER JOIN cammr_metasreuniones_cstm ON cammr_metasreuniones_cstm.id_c = cammr_metasreuniones.id WHERE deleted = 0 AND anno_c = '" . $anno . "' AND user_id_c = '" . $assigned_user_id . "';";
     $stmt = $this->container->get('doctrine')->getManager()->getConnection()->prepare($sql);
     $stmt->execute();
     $meta = 0;
     foreach ($stmt->fetchAll() as $data) {
         $meta = $data['sem_1_c'] + $data['sem_2_c'];
         $bar->append_stack(array(new \OFC_Charts_Bar_Stack_Value((int) $data['sem_1_c'], '#ff0000'), new \OFC_Charts_Bar_Stack_Value((int) $data['sem_2_c'], '#1240AB')));
     }
     $y = new \OFC_Elements_Axis_Y();
     $max = round(max($valor, $meta) * 1.15, 0);
     $y->set_range(0, $max, round($max, -3));
     $x = new \OFC_Elements_Axis_X();
     $x->set_labels_from_array(array('Reuniones', 'Metas'));
     $chart = new \OFC_Chart();
     $chart->set_bg_colour('#FFFFFF');
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_x_axis($x);
     $chart->add_y_axis($y);
     $response = new Response($chart->toPrettyString());
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
示例#12
0
 public function toObject()
 {
     $this->consolidateParameters();
     $xAxisLabels = new OFC_Elements_Axis_X_Label_Set();
     $xAxisLabels->set_labels($this->labels);
     $xAxisLabels->set_size(10);
     $xAxisLabels->set_colour('#444444');
     $xAxisLabels->set_steps($this->stepsX);
     $xAxis = new OFC_Elements_Axis_X();
     $xAxis->set_steps($this->stepsX);
     $xAxis->set_labels($xAxisLabels);
     $xAxis->set_colour('#CCCCCC');
     $xAxis->set_grid_colour('#AAAAAA');
     $this->chart->set_x_axis($xAxis);
     $yAxis = new OFC_Elements_Axis_Y();
     $yAxis->set_range($this->min1, $this->max1);
     $yAxis->set_colour('#AAAAAA');
     $yAxis->set_grid_colour('#AAAAAA');
     $yAxis->set_steps($this->stepsY1);
     $this->chart->set_y_axis($yAxis);
     $yLegend = new OFC_Elements_Legend_Y($this->data1->getName());
     //$this->chart->set_y_legend($yLegend); // does not work now
     // data 1
     $this->chart->add_element($this->createGraph($this->data1));
     if ($this->hasTwoDataLines()) {
         $yAxisRight = new OFC_Elements_Axis_Y_Right();
         $yAxisRight->set_range($this->min2, $this->max2);
         $yAxisRight->set_colour('#AAAAAA');
         $yAxisRight->set_steps($this->stepsY2);
         //            $this->chart->set_y_axis_right($yAxisRight);
         $this->chart->add_element($this->createGraph($this->data2));
     }
     return $this->chart;
 }
示例#13
0
/**
 * $array['title']
 * $array['legend_y']
 * $array['legend_x']
 * $array['values']
 * $array['values_key']
 * $array['range_max']
 * $array['range_step']
 * @param $array
 * @return unknown_type
 */
function create_chart_data($array)
{
    if (!$array) {
        return;
    }
    require_once 'OFC/OFC_Chart.php';
    $chart = new OFC_Chart();
    $chart->set_bg_colour('#ffffff');
    $title = new OFC_Elements_Title($array['title']);
    $title->set_style('{color: #567300; font-size: 16px; font-weight:bold;}');
    $chart->set_title($title);
    $yl = new OFC_Elements_Legend_Y($array['legend_y']);
    $yl->set_style('{font-size:18px;}');
    $chart->set_y_legend($yl);
    $xl = new OFC_Elements_Legend_X($array['legend_x']);
    $xl->set_style('{font-size:18px;color:#Ff0}');
    $chart->set_x_legend($xl);
    $elements = array();
    $colors = array('', '#CC00AA', '#9C48F0', '#b0de09', '#0d8ecf', '#ff6600', '#fcd202', '#E2EBFF', '#AAAAAA');
    foreach ($array['values'] as $k => $v) {
        ksort($v, SORT_STRING);
        $line = new OFC_Charts_Line();
        $line->set_key($array['values_key'][$k], 12);
        $colors[$k] ? $line->set_colour($colors[$k]) : '';
        $line->set_values(array_values($v));
        $default_dot = new OFC_Charts_Line_Dot();
        $default_dot->tooltip('#x_label#<br>#val#');
        $line->set_default_dot_style($default_dot);
        $elements[] = $line;
        $array['values'][$k] =& $v;
    }
    foreach ($elements as $element) {
        $chart->add_element($element);
    }
    $x = new OFC_Elements_Axis_X();
    $x->colour = '#909090';
    $x_axis_labels = new OFC_Elements_Axis_X_Label_Set();
    $x->set_steps($array['show_step']);
    $x_axis_labels->set_steps($array['show_step']);
    if (is_array($array['values'][0])) {
        $keys = array_keys($array['values'][0]);
    } else {
        $keys = array_keys($array['values']);
    }
    $x_axis_labels->set_labels($keys);
    $x_axis_labels->set_size(12);
    $x_axis_labels->set_colour('#Ff0');
    $x_axis_labels->set_rotate('-45');
    $x->set_labels($x_axis_labels);
    $chart->set_x_axis($x);
    $y = new OFC_Elements_Axis_Y();
    $range_min = isset($array['range_min']) ? $array['range_min'] : 0;
    $y->set_range($range_min, $array['range_max'], $array['range_step']);
    $chart->set_y_axis($y);
    return $chart->toPrettyString();
}
示例#14
0
    function pn_handle_options_page()
    {
        session_cache_limiter(FALSE);
        global $wpdb, $pn_plugin_url, $pn_plugin_dir;
        $action_url = $_SERVER['REQUEST_URI'];
        $unsent_mails = array();
        if (isset($_REQUEST['pnd'])) {
            $plimus_pn = $wpdb->prefix . "plimus_pn";
            $id = $_REQUEST['pnd'];
            $query_db = "DELETE FROM {$plimus_pn} WHERE pn_orn = {$id}";
            $delete = $wpdb->query($query_db);
        }
        $search_term = isset($_POST['search_item']) ? trim($_POST['search_item']) : '';
        $global_days = null;
        if (isset($_REQUEST['filter_all']) && !empty($_REQUEST['filter_all']) && !empty($search_term) && $search_term != 'Filter By Keyword') {
            $filter = isset($_SESSION['filter_by_type']) ? $_SESSION['filter_by_type'] : 'date';
            $global_days = isset($_REQUEST['filter_by_dates']) ? $_REQUEST['filter_by_dates'] : $_SESSION['filter_by_dates'];
            $terms = explode(" ", $search_term);
            $search_where = ' WHERE pn_meta_value LIKE ';
            foreach ($terms as $term) {
                $search_where .= "('%{$term}%') OR pn_meta_value LIKE ";
            }
            $search_where = substr_replace($search_where, '', -22);
            $search_data = $wpdb->get_results("SELECT pn.pn_orn FROM {$wpdb->prefix}plimus_pn as pn {$search_where}", OBJECT_K);
            if (!empty($search_data)) {
                $search_query = " WHERE pn.pn_orn IN ('" . implode("','", array_keys($search_data)) . "');";
            } else {
                $search_query = '';
            }
        } else {
            $filter = 'date';
            if (isset($_REQUEST['show']) && $_REQUEST['show'] == 'all') {
                $global_days = 0;
            }
            unset($_SESSION['filter_by_type']);
            unset($_SESSION['filter_by_dates']);
            $search_query = '';
        }
        if ($search_query != '') {
            $amount_data = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}plimus_pn as pn");
            $total_amount = array();
            if (!empty($amount_data)) {
                foreach ($amount_data as $key => $data) {
                    if ($data->pn_meta_key == 'invoiceAmountUSD' || $data->pn_meta_key == 'transactionDate') {
                        $total_amount[$data->pn_orn][$data->pn_meta_key] = $data->pn_meta_value;
                    }
                }
            }
            $this_month = 0;
            $last_month = 0;
            $total_sum = 0;
            foreach ($total_amount as $key => $data) {
                $total_sum += (double) $data['invoiceAmountUSD'];
                if (date('mY') == date('mY', strtotime($data['transactionDate']))) {
                    $this_month += (double) $data['invoiceAmountUSD'];
                }
                $lmonth = date('m') - 1;
                if (date('' . $lmonth . 'Y') == date('mY', strtotime($data['transactionDate']))) {
                    $last_month += (double) $data['invoiceAmountUSD'];
                }
            }
        }
        if (isset($_REQUEST['filter_all'])) {
            $filter = isset($_POST['filter_by_type']) ? $_POST['filter_by_type'] : $_SESSION['filter_by_type'];
            $_SESSION['filter_by_type'] = $filter;
        }
        $selected[$filter] = 'selected';
        if (isset($_REQUEST['filter_all']) && isset($_REQUEST['filter_by_dates']) && $_REQUEST['filter_by_dates'] != '0') {
            $global_days = isset($_REQUEST['filter_by_dates']) ? $_REQUEST['filter_by_dates'] : $_SESSION['filter_by_dates'];
            $_SESSION['filter_by_dates'] = $global_days;
        }
        $transaction_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}plimus_pn as pn {$search_query}"));
        $this_month = 0;
        $last_month = 0;
        $total_sum = 0;
        if (!empty($transaction_data)) {
            $default_footer = '</div>';
            $table_rows = array();
            $products = array();
            $products_date = array();
            $remove_row = array();
            $transactions = array();
            foreach ($transaction_data as $key => $data) {
                $transactions[$data->pn_orn][$data->pn_meta_key] = $data->pn_meta_value;
            }
            $firt_entry = 0;
            $j = 0;
            if (!empty($transactions)) {
                foreach ($transactions as $key => $data_array) {
                    $item = '';
                    $promotions_array = array();
                    $days_past = (int) (strtotime('today') / 86400 - strtotime($data_array['transactionDate']) / 86400);
                    $firt_entry = $days_past > $firt_entry ? $days_past : $firt_entry;
                    if (!empty($data_array)) {
                        //$key++;
                        $invoice_url = preg_match('/http\\:\\/\\//i', $data_array['invoiceInfoURL']) ? $data_array['invoiceInfoURL'] : 'http://' . $data_array['invoiceInfoURL'];
                        $company = $data_array['company'] != '' ? "<font style='font-weight: bold;' >Coustomer company: </font>{$data_array['company']} <br />" : '';
                        $address1 = $data_array['address1'] != '' ? "<font style='font-weight: bold;' >Coustomer address one: </font>{$data_array['address1']} {$data_array['zipCode']},{$data_array['city']}, {$data_array['state']}, {$data_array['country']} <br />" : '';
                        $address2 = $data_array['address2'] != '' ? "<font style='font-weight: bold;' >Coustomer address two: </font>{$data_array['address2']} <br />" : '';
                        $contact = $data_array['email'] != '' ? "<font style='font-weight: bold;' >Coustomer contact: </font> {$data_array['workPhone']} / {$data_array['extension']} " : '';
                        $mobile_phone = $data_array['mobilePhone'] != '' ? "<font style='font-weight: bold;' > mobile: </font> {$data_array['mobilePhone']}" : '';
                        $home_phone = $data_array['homePhone'] != '' ? "<font style='font-weight: bold;' > home: </font>{$data_array['homePhone']}" : '';
                        $fax = $data_array['faxNumber'] != '' ? "<font style='font-weight: bold;' > fax: </font>{$data_array['faxNumber']} <br />" : '';
                        $coustomer_cc = $data_array['creditCardType'] != '' ? "<font style='font-weight: bold;' > Credit card: </font>{$data_array['creditCardType']} <br />" : '';
                        $ship_to = $data_array['shippingFirstName'] != '' || $data_array['shippingLastName'] != '' ? " <font style='font-weight: bold;' >Shiping To: </font>{$data_array['shippingFirstName']} {$data_array['shippingLastName']} {$data_array['shippingZipCode']} {$data_array['shippingCity']} {$data_array['shippingState']} {$data_array['shippingCountry']}" : '';
                        $shippingMethod = $data_array['shippingMethod'] != '' ? " <font style='font-weight: bold;' > shiping method: </font> {$data_array['shippingMethod']}<br />" : '';
                        $invoiceChargeAmount = $data_array['invoiceChargeAmount'] != '' ? " <font style='font-weight: bold;' >Invoice Amount: </font> {$data_array['invoiceChargeAmount']} {$data_array['invoiceChargeCurrency']} (\$ {$data_array['invoiceAmountUSD']}) <a href='{$invoice_url}' target='_blank'>{$data_array['invoiceInfoURL']}</a><br />" : '';
                        $coupon = $data_array['coupon'] != '' ? "<font style='font-weight: bold;' >Used a coupon: </font> {$data_array['coupon']} " : '';
                        $couponCode = $data_array['couponCode'] != '' ? " <font style='font-weight: bold;' > code: </font>  {$data_array['couponCode']} " : '';
                        $couponValue = $data_array['couponValue'] != '' ? "  <font style='font-weight: bold;' >amount: </font>  {$data_array['couponValue']} {$data_array['invoiceChargeCurrency']} " : '';
                        $referrer = $data_array['referrer'] != '' ? " <font style='font-weight: bold;' > referer: </font>  {$data_array['referrer']} <br />" : '';
                        $table_coupon = $data_array['coupon'] != '' ? "{$data_array['coupon']} ({$data_array['couponCode']})" : '';
                        $coupon = (double) str_replace(',', '', $data_array['couponValue']);
                        $promotions_html = '';
                        $currency = $data_array['currency'];
                        $tr_date = str_replace(' ', '/', substr_replace((string) $data_array['transactionDate'], '', -9));
                        $charge = 0;
                        if ($tr_date != '') {
                            $product_name = $data_array['productName'];
                            if ($filter == 'contract') {
                                $product_name = $data_array['contractName'];
                            }
                            $charge = str_replace(',', '.', $data_array['invoiceAmountUSD']);
                            $products[$tr_date][$key] = array('amount' => isset($products[$tr_date][$product_name]) && in_array($transactiontype, array('CHARGE', 'RECURRING')) ? (double) $products[$tr_date][$product_name] + (double) $charge : 0, 'name' => $product_name);
                        }
                        if ($data_array['promoteContractsNum'] > 0) {
                            for ($i = 0; $i < $data_array['promoteContractsNum']; $i++) {
                                $promotions_html .= '<font style="font-weight: bold;" > Promotion: </font> ' . $data_array["promoteContractName{$i}"] . '
								<font style="font-weight: bold;" > owner: </font> ' . $data_array["promoteContractOwner{$i}"] . '
								<font style="font-weight: bold;" > price: </font> ' . $data_array["promoteContractPrice{$i}"] . '
								<font style="font-weight: bold;" > qty: </font> ' . $data_array["promoteContractQuantity{$i}"] . '
								<font style="font-weight: bold;" > licence: </font> ' . $data_array["promoteContractLicenseKey{$i}"] . '<br />';
                            }
                        }
                        $remove_row[$tr_date][] = $key;
                        $productname = isset($data_array['productName']) ? $data_array['productName'] : '';
                        $contractname = isset($data_array['contractName']) ? $data_array['contractName'] : '';
                        $quantity = isset($data_array['quantity']) ? $data_array['quantity'] : '';
                        $invoiceamountusd = isset($data_array['invoiceAmountUSD']) ? $data_array['invoiceAmountUSD'] : '';
                        $paymentmethod = isset($data_array['paymentMethod']) ? $data_array['paymentMethod'] : '';
                        $transactiontype = isset($data_array['transactionType']) ? $data_array['transactionType'] : '';
                        $prtitle = isset($data_array['title']) ? $data_array['title'] : '';
                        $firstname = isset($data_array['firstName']) ? $data_array['firstName'] : '';
                        $lastname = isset($data_array['lastName']) ? $data_array['lastName'] : '';
                        $premail = isset($data_array['email']) ? $data_array['email'] : '';
                        $transactiondate = isset($data_array['transactionDate']) ? $data_array['transactionDate'] : '';
                        $table_rows[$key] = "<tr><td>{$productname}</td><td>{$contractname}</td><td>{$quantity}</td>\n\t\t\t\t\t\t\t<td>{$invoiceamountusd}</td><td> {$table_coupon}</td><td>{$paymentmethod}</td>\n\t\t\t\t\t\t\t<td>{$transactiontype}</td><td>{$prtitle} {$firstname} {$lastname}</td><td>{$premail}</td>\n\t\t\t\t\t\t\t<td>{$transactiondate}</td><td id='more-info-{$key}'><a href='javascript: void(0)' title='More Info' onclick='showMoreInfo({$key})'>More</a> </td>\n\t\t\t\t\t\t\t<td style='background: #f9f9f9;'>\n\t\t\t\t\t\t\t\t<div class='more-info-panel' id='mi-{$key}' style='display: none;'>\n\t\t\t\t\t\t\t\t\t{$company}{$address1}{$address2}{$contact}{$mobile_phone}{$home_phone}{$fax}{$coustomer_cc}{$ship_to}{$shippingMethod}{$invoiceChargeAmount}\n\t\t\t\t\t\t\t\t\t{$coupon}{$couponCode}{$couponValue}{$referrer}\n\t\t\t\t\t\t\t\t\t" . $promotions_html . "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</td></tr>";
                        $un_date = str_replace(' ', '/', substr_replace($transactiondate, '', -9));
                        $unsent_mails[] = array($un_date, $premail);
                    }
                    $j++;
                }
            }
            if ($search_query == '') {
                foreach ($products as $date => $data) {
                    foreach ($data as $key => $value) {
                        $total_sum += (double) $value['amount'];
                        if (date('mY') == date('mY', strtotime($date))) {
                            $this_month += $value['amount'];
                        }
                        $lmonth = $current_month = date('m') - 1;
                        if (date('' . $lmonth . 'Y') == date('mY', strtotime($date))) {
                            $last_month += $value['amount'];
                        }
                    }
                }
            }
            // sort by days
            $selected_date = array(0 => '', 7 => '', 15 => '', 30 => '', 60 => '', 120 => '');
            //if($filter == 'date'){
            $has_results = false;
            $global_days = $global_days == 0 ? $firt_entry : $global_days;
            $selected_date[$global_days] = 'selected="selected"';
            while (!$has_results) {
                $results = array();
                $data_dates = array();
                for ($i = 0; $i < (int) $global_days; $i++) {
                    $date = date('m/d/Y', time() - $i * 86400);
                    $data_dates[$i] = $date;
                }
                $keys = array_keys($products);
                foreach ($data_dates as $date) {
                    if (!array_key_exists($date, $products)) {
                        $products[$date][] = array();
                        $results[$date] = false;
                        continue;
                    }
                    $results[$date] = true;
                }
                foreach ($results as $res) {
                    if ($res) {
                        $has_results = true;
                        break;
                    }
                }
                if (!$has_results) {
                    if ($global_days = 0) {
                        $global_days = 7;
                    } else {
                        if ($global_days = 7) {
                            $global_days = 15;
                        } else {
                            $global_days = 2 * $global_days;
                        }
                    }
                }
                if ($global_days > 120) {
                    break;
                }
            }
            if ($global_days != 0 && false) {
                foreach ($keys as $key) {
                    if (!in_array($key, $data_dates) && isset($remove_row[$key])) {
                        foreach ($remove_row[$key] as $row_id) {
                            unset($table_rows[$row_id]);
                        }
                        unset($products[$key]);
                    }
                }
            }
            foreach ((array) $products as $date => $data) {
                $date_key = strtotime($date);
                foreach ($data as $key => $value) {
                    $products[$date_key][$key] = $value;
                }
                unset($products[$date]);
            }
            ksort($products);
            foreach ($products as $date => $data) {
                $date_key = date('m/d/Y', $date);
                foreach ($data as $key => $value) {
                    $products[$date_key][$key] = $value;
                }
                unset($products[$date]);
            }
            //}
            // end sort by days
            /* json */
            require_once 'pn-chart/OFC/OFC_Chart.php';
            $title_is = '';
            $values = array();
            $tips = array();
            $bar = new OFC_Charts_Bar();
            $max_price = 0;
            $amount = array();
            $array_keys = array_keys($products);
            foreach ($products as $date => $data) {
                if ($filter == 'date') {
                    $price = array();
                    foreach ($data as $key => $value) {
                        if (!isset($price[$date])) {
                            $price[$date] = 0;
                        }
                        $price[$date] += isset($value['amount']) ? $value['amount'] : 0;
                    }
                    $price = (double) $price[$date] < 0 ? 0 : (double) $price[$date];
                    $x_label[] = new OFC_Elements_Axis_X_Label('$' . $price, '#999999', 10, -50);
                    $tip_price = number_format($price, 2, '.', ',');
                    $tip = "\${$tip_price} ({$date})";
                    $val = new OFC_Charts_Bar_Value($price);
                    $val->set_tooltip($tip);
                    $values[] = $val;
                    $max_price = $max_price < $price ? $price + $price / 4 : $max_price;
                } else {
                    if ($date != $array_keys[count($array_keys) - 1]) {
                        foreach ($data as $key => $value) {
                            if (!empty($value) && isset($value['amount'])) {
                                if (!isset($amount[$value['name']])) {
                                    $amount[$value['name']] = 0;
                                }
                                $amount[$value['name']] += $value['amount'];
                            }
                        }
                        continue;
                    }
                    foreach ($data as $key => $value) {
                        if (!empty($value)) {
                            $amount[$value['name']] += $value['amount'];
                        }
                    }
                    foreach ($amount as $product_name => $product_val) {
                        $x_label[] = new OFC_Elements_Axis_X_Label(str_replace('|', ' ', $product_name), '#999999', 10, -50);
                        $tip_price = number_format($product_val, 2, '.', ',');
                        $tip = ucwords($product_name) . " (\$ {$tip_price})";
                        $val = new OFC_Charts_Bar_Value($product_val);
                        $val->set_tooltip($tip);
                        $values[] = $val;
                        $max_price = $max_price < $product_val ? $product_val + $product_val / 4 : $max_price;
                    }
                }
            }
            $bar->set_colour('#119CD3');
            $bar->set_values($values);
            $title = new OFC_Elements_Title($title_is);
            $x_l_set = new OFC_Elements_Axis_X_Label_Set();
            $x_l_set->set_steps(1);
            $x_l_set->set_labels($x_label);
            $x_axis = new OFC_Elements_Axis_X();
            $x_axis->set_3d(0);
            $x_axis->set_colours('#DDDDDD', '#DDDDDD');
            $x_axis->set_stroke(1);
            $x_axis->set_labels($x_l_set);
            $step = $max_price > 500 ? $max_price > 5000 ? $max_price > 50000 ? $max_price > 500000 ? $max_price > 5000000 ? 5000000 : 500000 : 50000 : 5000 : 500 : 50;
            $y_axis = new OFC_Elements_Axis_Y();
            $y_axis->set_colours('#DDDDDD', '#DDDDDD');
            $y_axis->set_range(0, $max_price, $step);
            $chart = new OFC_Chart();
            $chart->set_title($title);
            $chart->set_bg_colour('#F9F9F9');
            $chart->set_x_axis($x_axis);
            $chart->set_y_axis($y_axis);
            $chart->add_element($bar);
            $path = $pn_plugin_dir . "/pn-chart/data.json";
            $file = @fopen($path, "w");
            @fwrite($file, $chart->toString());
            @fclose($file);
            /* end json */
            $result = '';
            if (isset($_REQUEST['filter_all']) && $search_term != 'Filter By Keyword' && $search_term != '' && count($table_rows)) {
                $result = '<i style="color: #777">Showing results for "<strong>' . $search_term . '</strong>"</i>';
            } else {
                if (isset($_REQUEST['filter_all']) && $search_term != 'Filter By Keyword' && $search_term != '' && !count($table_rows)) {
                    $result = '<i style="color: #777">There is no transactions in this time period, that contain <strong>"' . $search_term . '"</strong>. Select your timespan in filter section.</i>';
                }
            }
            $master_table = $result . "<br /><br /><table id='pn-table-main' class='tablesorter'>";
            $master_table .= "<thead><tr><th> Product name </th><th> Contract name </th><th> Qty </th>\n\t\t\t\t<th> Invoice amount (USD)</th><th> Coupon code</th><th> Method </th><th> Transaction type</th><th> Customer name </th><th> Customer email </th><th> Transaction Date </th><td></td></tr></thead><tbody>";
            $master_table .= implode('', $table_rows) . "</tbody></table>";
            $master_table .= <<<END
\t\t\t\t\t\t\t<div id="pager" class="pager">
\t\t\t\t\t\t\t\t<form>
\t\t\t\t\t\t\t\t\t\t<img src="{$pn_plugin_url}/images/first.png" class="first"/>
\t\t\t\t\t\t\t\t\t\t<img src="{$pn_plugin_url}/images/prev.png" class="prev"/>
\t\t\t\t\t\t\t\t\t\t<input type="text" style="width:50px; height:18px; padding: 0px 0px 3px 0px;" class="pagedisplay" />
\t\t\t\t\t\t\t\t\t\t<img src="{$pn_plugin_url}/images/next.png" class="next"/>
\t\t\t\t\t\t\t\t\t\t<img src="{$pn_plugin_url}/images/last.png" class="last"/>
\t\t\t\t\t\t\t\t\t\t<select class="pagesize">
\t\t\t\t\t\t\t  <option value="5">5 per page</option>
\t\t\t\t\t\t\t\t\t\t\t\t<option value="10">10 per page</option>
\t\t\t\t\t\t\t\t\t\t\t\t<option value="20">20 per page</option>
\t\t\t\t\t\t\t\t\t\t\t\t<option value="50" selected="selected">50 per page</option>

\t\t\t\t\t\t\t\t\t\t</select>
\t\t\t\t\t\t\t\t</form>
\t\t\t\t\t\t</div>
END;
        }
        ?>
		<script type="text/javascript">
			swfobject.embedSWF("<?php 
        echo $pn_plugin_url . "/pn-chart/open-flash-chart.swf";
        ?>
", "pn_chart", "900px", "220px", "9.0.0", "expressInstall.swf", {"data-file":"<?php 
        echo $pn_plugin_url;
        ?>
/pn-chart/data.json"});
		</script>
		<div class="wrap">
		<h2><a href="http://www.bluesnap.com" title="Bluesnap - Take charge" target="_blank"><img src="<?php 
        echo $pn_plugin_url;
        ?>
/images/plimus_logo.png" alt="Plimu IPN" id="plimus-logo" /></a>for WordPress</h2>
		
		<h5><font color="#999999">This Month:</font> <font color="#555555"> $<?php 
        echo number_format($this_month, 2, '.', ',');
        ?>
</font> &nbsp;&nbsp;|&nbsp;&nbsp; <font color="#999999"> Last Month:</font> <font color="#555555"> $<?php 
        echo number_format($last_month, 2, '.', ',');
        ?>
</font> &nbsp;&nbsp;|&nbsp;&nbsp;  <font color="#999999"> Total Amount:</font> <font color="#555555"> $<?php 
        echo number_format($total_sum, 2, '.', ',');
        ?>
</font> </h5>
			<!--<i id="small_size">* Send registration notifications (again), dates in mm/dd/yyyy format please</i>
			 <form action="<?php 
        //echo $action_url;
        ?>
" method="post" id="new_email_form" >
				From <input type="text" name="new_from_date" value="12/1/2010" /> to <input type="text" name="new_to_date" value="12/16/2010" />
				<input type="submit" name="new_mails_submit" id="new_mails_submit" value="Send Registration Emails" class="button"/><br />
					<br /><i id="note">&nbsp;&nbsp;&nbsp;&nbsp;** in your <b>HTML new password email</b> template use <code>{USER_FULL_NAME}</code> <code>{NEW_PASSWORD}</code> <code>{LOGIN_URL}</code> shortcodes, to replace it with user</i>
				<textarea cols="90" rows="10" name="pn_email_tmp" id="pn_email_tmp" ><?php 
        //echo $pn_tpl_reg_email_text
        ?>
</textarea><div id="legend"></div>
				<textarea cols="80" rows="10" name="pn_email_res" id="pn_email_res" ><?php 
        //echo $email_message
        ?>
</textarea><div id="legend"></div>
			</form><br /><br /> -->
		<form action="<?php 
        echo $action_url;
        ?>
" id="search_form" method="POST">
			<select name="filter_by_type" id="filter_by_type" >
				<option value="date" <?php 
        echo isset($selected['date']) ? $selected['date'] : '';
        ?>
 >Show by date</option>
				<option value="product" <?php 
        echo isset($selected['product']) ? $selected['product'] : '';
        ?>
 >Show by product</option>
				<option value="contract" <?php 
        echo isset($selected['contract']) ? $selected['contract'] : '';
        ?>
 >Show by contract</option>
			</select>
			<select name="filter_by_dates" id="filter_by_dates" >
				<option value="0" <?php 
        echo $selected_date[0];
        ?>
>All transactions</option>
				<option value="7" <?php 
        echo $selected_date[7];
        ?>
>Last 7 days</option>
				<option value="15" <?php 
        echo $selected_date[15];
        ?>
>Last 15 days</option>
				<option value="30" <?php 
        echo $selected_date[30];
        ?>
>Last 30 days</option>
				<option value="60" <?php 
        echo $selected_date[60];
        ?>
>Last 60 days</option>
				<option value="120" <?php 
        echo $selected_date[120];
        ?>
>Last 120 days</option>
			</select>
			<input type="text" name="search_item" id="search_item" size="40" value="<?php 
        $search_term = strlen(trim($search_term)) ? $search_term : 'Filter By Keyword';
        echo $search_term;
        ?>
" />
			
			<input type="submit" value=" Submit  " name="filter_all" class="button" />
			<a href="<?php 
        echo $action_url;
        ?>
&show=all" title="Show All" class="button"> Show All </a>
		</form>
	<br />
		<?php 
        if (!empty($transaction_data)) {
            ?>
			<br />
			<div id="resize" style="width:1000px; height:250px; padding: 10px;">
				<div id="pn_chart"></div>
			</div>
			<?php 
            echo $master_table . $default_footer;
        } else {
            if (isset($_REQUEST['filter_all']) && ($search_term != '' || $search_term != 'Filter By Keyword') && empty($transaction_data)) {
                echo "<h5></i>There are no results for '{$_POST['search_item']}'.</i></h5>";
            } else {
                echo "<h5></i>There are no registered sales yet, but hopefully things are about to change.</i></h5>";
            }
        }
        ?>
		<h5><a href="http://www.prelovac.com" title="Plugin by Prelovac Media"><img src="<?php 
        echo $pn_plugin_url;
        ?>
/images/logo.png"  style="margin-top: 30px;"/></a> </h5>
		
		</div><br />
		
		<?php 
    }