예제 #1
0
 function indexAction()
 {
     //		$this->_helper->layout->disableLayout();
     //		$login = "******";
     //		$password = "******";
     //		include_once 'sina.php';
     //		$resultarray = get_sinacontacts($login, $password);
     //		Zend_Debug::dump($resultarray);
     //		include_once '163.php';
     //		$login = '******';
     //		$password = '******';
     //		$resultarray = get_163contacts($login, $password);
     //		Zend_Debug::dump($resultarray);
     //		include_once 'yahoo.php';
     //		$obj = new GrabYahoo();
     //		$contacts = $obj->getAddressbook('*****@*****.**','19990402');
     //		Zend_Debug::dump($contacts);
     //		include_once "contacts_fn.php";
     //		$ret_array = get_msncontacts('*****@*****.**', '1999040211');
     //		Zend_Debug::dump($ret_array);
     //		$this->_helper->layout->setLayout("layout_admin");
     $this->_helper->layout->disableLayout();
     // get date from db
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('report', array('left(create_date,10) as date', 'accesscode'))->where('report.campaign_id = 3')->where("report.state = 'APPROVED'")->order('date');
     $results = $db->fetchAll($select);
     $accesscodeDbMatchArray = array();
     foreach ($results as $result) {
         $accesscodeDbMatchArray[$result['accesscode']] = $result['date'];
     }
     $accesscodeArray = array_keys($accesscodeDbMatchArray);
     //		Zend_Debug::Dump($accesscodematchArray);
     // get value from ws
     $indicate2Connect = new Indicate2_Connect();
     $response = $indicate2Connect->getAnswerSetForSurvey(385, null, array(array('ContextIndex' => 1, 'QuestionIndex' => 1), array('ContextIndex' => 1, 'QuestionIndex' => 4)), 0);
     //        Zend_Debug::Dump($response);
     $talkingdurationArray = array();
     $accesscodeResponseMathArray = array();
     if (isset($response->AnswerSetType)) {
         foreach ($response->AnswerSetType as $answerSet) {
             if (isset($answerSet->AnswerType) && is_array($answerSet->AnswerType) && !empty($answerSet->AnswerType)) {
                 foreach ($answerSet->AnswerType as $answer) {
                     if ($answer->QuestionId == 573) {
                         $accesscodeResponseMathArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answer->AnswerText)));
                     }
                     if ($answer->QuestionId == 576) {
                         $talkingdurationArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answer->AnswerText)));
                     }
                 }
             } else {
                 //get min value, like '11-15' = 11
                 $accesscodeResponseMathArray[$answerSet->AccessCode] = (int) iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answerSet->AnswerType->AnswerText)));
             }
         }
     }
     //		Zend_Debug::Dump($accesscodeResponseMathArray);
     //		Zend_Debug::Dump($talkingdurationArray);
     $resultmatchArray = array();
     foreach ($accesscodeArray as $accesscode) {
         $resultmatchArray[$accesscodeDbMatchArray[$accesscode]] = 0;
     }
     foreach ($accesscodeArray as $accesscode) {
         if (array_key_exists($accesscode, $accesscodeResponseMathArray)) {
             $resultmatchArray[$accesscodeDbMatchArray[$accesscode]] += $accesscodeResponseMathArray[$accesscode];
         }
     }
     //		 Zend_Debug::Dump($resultmatchArray);
     $dateArray = array_keys($resultmatchArray);
     foreach ($dateArray as $date) {
         $resultmatchArray[$date] = floor($resultmatchArray[$date] * 1.65);
     }
     //        Zend_Debug::Dump($resultmatchArray);
     include 'open-flash-chart.php';
     $data_1 = array();
     $base = floor(1472 * 1.65);
     $temp = 0;
     $resultmatchArray[0] = 0;
     foreach ($dateArray as $date) {
         $resultmatchArray[$date] += $resultmatchArray[$temp];
         $data_1[] = $resultmatchArray[$date] + $base;
         $temp = $date;
     }
     //		Zend_Debug::Dump($data_1);
     $title = new title("Impressions of BugsLock by day");
     $y = new y_axis();
     $y->set_range(0, 40000, 10000);
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($dateArray);
     $x_labels->set_steps(2);
     $x_labels->rotate(40);
     $x->set_labels($x_labels);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour('#f00000')->tooltip('#x_label#: #val#');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($data_1);
     $line_1->set_width(1);
     $line_1->set_key('Impression', 10);
     $this->view->chart = new open_flash_chart();
     $this->view->chart->set_title($title);
     $this->view->chart->add_element($line_1);
     $this->view->chart->set_y_axis($y);
     $this->view->chart->set_x_axis($x);
     $this->view->chart->set_bg_colour('#FFFFFF');
     //
     include 'ofc_sugar.php';
     $this->view->chart2 = new open_flash_chart();
     $this->view->chart2->set_title(new title('Generation Chart'));
     $line_1 = new line();
     $array_1 = array();
     $f = 1.5;
     for ($i = 0; $i <= 50; $i++) {
         array_push($array_1, $f);
     }
     $line_1->set_values($array_1);
     //		$line_1->set_default_dot_style( new s_hollow_dot('#FBB829', 4) );
     $line_1->set_width(1);
     $line_1->set_colour('#FF0000');
     $line_1->set_tooltip("Gen0");
     $line_1->set_key('Gen0', 10);
     $line_1->loop();
     $area = new area();
     // set the circle line width:
     $area->set_width(1);
     //		$area->set_default_dot_style( new s_hollow_dot('#45909F', 5) );
     $area->set_colour('#FF0000');
     //		$area->set_fill_colour( '#FF0000' );
     //		$area->set_fill_alpha( 0.4 );
     $area->set_loop();
     $area->set_values($array_1);
     $line_2 = new line();
     $array_2 = array();
     $f = 2.8;
     for ($i = 0; $i <= 50; $i++) {
         array_push($array_2, $f);
     }
     $line_2->set_values($array_2);
     //		$line_2->set_default_dot_style( new s_hollow_dot('#FBB829', 4) );
     $line_2->set_width(1);
     $line_2->set_colour('#FBB829');
     $line_2->set_tooltip("Gold<br>#val#");
     $line_2->set_key('Gen1', 10);
     $line_2->loop();
     $line_4 = new line();
     $array_4 = array();
     $f = 5;
     for ($i = 0; $i <= 50; $i++) {
         array_push($array_4, $f);
     }
     $line_4->set_values($array_4);
     //		$line_2->set_default_dot_style( new s_star('#8000FF', 4) );
     $line_4->set_width(1);
     $line_4->set_colour('#3030D0');
     $line_4->set_tooltip("Purple<br>#val#");
     $line_4->set_key('Gen2', 10);
     $line_4->loop();
     // add the area object to the chart:
     $this->view->chart2->add_element($line_1);
     $this->view->chart2->add_element($line_2);
     $this->view->chart2->add_element($line_4);
     $r = new radar_axis(5);
     $r->set_colour('#FFFFFF');
     $r->set_grid_colour('#FFFFFF');
     $labels = new radar_axis_labels(array('G0', '', 'G1', '', 'G2'));
     $labels->set_colour('#9F819F');
     $r->set_labels($labels);
     $this->view->chart2->set_radar_axis($r);
     $tooltip = new tooltip();
     $tooltip->set_proximity();
     $this->view->chart2->set_tooltip($tooltip);
     $this->view->chart2->set_bg_colour('#ffffff');
     //		echo $this->view->chart2->toPrettyString();
 }
예제 #2
0
     $line_max->set_width( 1 );	
     $line_max->set_key( 'Max (W)', 10 );
     $line_max->set_tooltip( "#val# W" );
 */
 $line_watt_default_dot = new dot();
 $line_watt_default_dot->size(4)->colour('#f00000');
 $line_watt = new area();
 $line_watt->set_default_dot_style($line_watt_default_dot);
 $line_watt->set_values($data_watt);
 $line_watt->set_colour('#4D4D4D');
 $line_watt->set_fill_colour('#EFC01D');
 $line_watt->set_fill_alpha(0.75);
 $line_watt->set_width(2);
 $line_watt->set_key('Leistung (W)', 10);
 $line_watt->set_tooltip("#val# W");
 $line_tot_default_dot = new dot();
 $line_tot_default_dot->size(4)->halo_size(2);
 $line_tot = new line();
 $line_tot->set_default_dot_style($line_tot_default_dot);
 $line_tot->set_values($data_tot);
 $line_tot->set_colour('#A0A000');
 $line_tot->set_width(2);
 $line_tot->set_key('Gesamt (kWh)', 10);
 $line_tot->set_tooltip("#val# kWh");
 $max = max(max($data_watt), $max_val) * 1.15;
 $y = new y_axis();
 $y->set_range(0, $max, round($max * 0.1, -1));
 $x_labels = new x_axis_labels();
 $x_labels->set_vertical();
 $x_labels->set_steps(6);
 $x_labels->set_colour('#333333');
    $lv->tooltip('Manual Refill Qty (#x_label#) = #val# .');
    $data_4[] = $lv;
    if ($qty > $data_max) {
        $data_max = $qty;
    }
}
$line_4 = new line();
$line_4->set_values($data_4);
$line_4->set_colour($data_4_color);
$line_4->set_width(1);
//CREATE DATA 5 (SOLD HISTORY QTY)
$data_5_color = '#ff69b4';
$data_5 = array();
foreach ($daily_sold as $date => $qty) {
    $kw = $k + 1;
    $lv = new dot($qty);
    $lv->colour($data_5_color)->size(1);
    $lv->tooltip('Order Qty (#x_label#) = #val# .');
    $data_5[] = $lv;
    if ($qty > $data_max) {
        $data_max = $qty;
    }
}
$line_5 = new line();
$line_5->set_values($data_5);
$line_5->set_colour($data_5_color);
$line_5->set_width(1);
//CHECK MAX VALUE TO DEFINE BEST VERTICAL STEPS
if ($data_max <= 10) {
    $data_step = 1;
} else {
예제 #4
0
파일: product.php 프로젝트: jianoll/razor
 function getNewUsersByTime($timePhase, $fromDate = '', $toDate = '')
 {
     $this->load->library('ofc');
     $userId = $this->common->getUserId();
     $this->ofc->open_flash_chart();
     $this->ofc->set_bg_colour(CHART_BG_COLOR);
     $toTime = date("Y-m-d", strtotime("-1 day"));
     if ($timePhase == "7day") {
         $fromTime = date("Y-m-d", strtotime("-8 day"));
         $color = CHART_LINE_1;
         $key = "近7日新增用户";
         $title = new title("近7日新增用户统计");
     }
     if ($timePhase == "1month") {
         $title = new title("近30天新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-31 day"));
         $color = CHART_LINE_2;
         $key = "近30天新增用户统计";
     }
     if ($timePhase == "3month") {
         $title = new title("近三个月新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-92 day"));
         $color = CHART_LINE_3;
         $key = "近三个月新增用户统计";
     }
     if ($timePhase == "all") {
         $title = new title("所有新增用户统计");
         $fromTime = '1970-01-01';
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     if ($timePhase == "any") {
         $title = new title("所有新增用户统计");
         $fromTime = $fromDate;
         $toTime = $toDate;
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     $fromTime = $this->product->getUserStartDate($userId, $fromTime);
     $query = $this->newusermodel->getNewUsersByUserId($fromTime, $toTime, $userId);
     $data = array();
     $maxY = 0;
     $recordCount = $query->num_rows();
     $steps = $recordCount - 1 <= 10 ? 2 : (int) (((int) $recordCount - 1) / 10);
     $xlabelArray = array();
     if ($query != null && $query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $dot = new dot();
             $dot->size(3)->halo_size(1)->colour($color);
             $dot->tooltip($row->startdate . " 新增" . $row->totalusers . "用户");
             $dot->value((int) $row->totalusers);
             if ((int) $row->totalusers > $maxY) {
                 $maxY = (int) $row->totalusers;
             }
             array_push($xlabelArray, date('y-m-d', strtotime($row->startdate)));
             array_push($data, $dot);
         }
     }
     $y = new y_axis();
     $y->set_range(0, $this->common->getMaxY($maxY), $this->common->getStepY($maxY));
     $x = new x_axis();
     $x->set_range(0, $recordCount > 1 ? $recordCount - 1 : 1);
     $x_labels = new x_axis_labels();
     $x_labels->set_steps($steps);
     $x_labels->set_vertical();
     $x_labels->set_colour(CHART_LABEL_COLOR);
     $x_labels->set_size(13);
     $x_labels->set_labels($xlabelArray);
     $x_labels->rotate(-25);
     $x->set_labels($x_labels);
     $x->set_steps(1);
     $this->ofc->set_y_axis($y);
     $this->ofc->set_x_axis($x);
     $dot = new dot();
     $dot->size(3)->halo_size(1)->colour($color);
     $line = new line();
     $line->set_default_dot_style($dot);
     $line->set_values($data);
     $line->set_width(2);
     $line->set_colour($color);
     $line->colour($color);
     $line->set_key($key, 12);
     $this->ofc->add_element($line);
     $title->set_style("{font-size: 14px; color:#000000; font-family: Verdana; text-align: center;}");
     // 		$x_legend = new x_legend("<a href=\"javascript:changeChartName('chartNewUser')\">新增用户</a> <a href=\"javascript:changeChartName('chartActiveUser')\">活跃用户</a> <a href=\"javascript:changeChartName('chartStartUser')\">启动用户</a>");
     // 		$this->ofc->set_x_legend( $x_legend );
     // 		$x_legend->set_style( '{font-size: 14px; color: #778877}' );
     $this->ofc->set_title($title);
     echo $this->ofc->toPrettyString();
 }
예제 #5
0
$x_labels = array();
$amt_max = $total_data[0]->amount;
$amt_min = $total_data[0]->amount;
$amt_count = 0;
$date_count = 0;
foreach ($total_data as $data_item) {
    $val = round($data_item->last_change, 2);
    $val2 = round($data_item->sofyr_return, 2);
    $val3 = round($data_item->first_return, 2);
    $amt = round($data_item->amount, 2);
    //ChromePhp::log($data_item);
    $year = $data_item->year;
    $month = $data_item->month;
    $day = $data_item->day;
    if ($amt_count % $amt_stride == 0) {
        $dot = new dot($amt);
        if ($val > 0.0) {
            $returns[] = $dot->colour('#006600')->tooltip("{$month}/{$day}/{$year}\n\${$amt}\nYesterday: {$val}%\nYear-to-Date: {$val2}%\nInception: {$val3}%");
        } else {
            $returns[] = $dot->colour('#FF0000')->tooltip("{$month}/{$day}/{$year}\n\${$amt}\nYesterday: {$val}%\nYear-to-Date: {$val2}%\nInception: {$val3}%");
        }
    }
    $amt_count++;
    if ($amt > $amt_max) {
        $amt_max = $amt;
    }
    if ($amt < $amt_min) {
        $amt_min = $amt;
    }
    if ($date_count % $amt_stride == 0) {
        if ($date_count % $date_stride == 0) {
예제 #6
0
}
$title = new title("How far from the budget I was each month");
sort($labellist);
$x_labels = new x_axis_labels();
$x_labels->rotate(45);
$x_labels->set_labels($labellist);
$x = new x_axis();
$x->set_labels($x_labels);
$y = new y_axis();
$y->set_range(round($min) * 1.1, round($max) * 1.1);
$y->set_label_text("\$#val#");
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
$chart->set_bg_colour('#FFFFFF');
foreach ($categorylist as $category) {
    $color = "#" . substr(md5($category), 0, 6);
    $default_dot = new dot();
    $default_dot->size(3)->colour($color)->tooltip('#key#:<br>$#val#');
    $l = new line();
    $l->set_default_dot_style($default_dot);
    $l->set_values($datalist[$category]);
    $l->set_key($category, 12);
    $l->set_colour($color);
    $chart->add_element($l);
}
echo $chart->toPrettyString();
?>

예제 #7
0
$line_sma15_default_dot->colour('#5E1999');
$line_sma15 = new line();
$line_sma15->set_default_dot_style($line_sma15_default_dot);
$line_sma15->set_values($sma15);
$line_sma15->set_width(1);
$line_sma15->set_colour("#5E1999");
$line_sma15->set_key("SMA15", 12);
$line_sma10_default_dot = new dot();
$line_sma10_default_dot->colour('#DEA325');
$line_sma10 = new line();
$line_sma10->set_default_dot_style($line_sma10_default_dot);
$line_sma10->set_values($sma10);
$line_sma10->set_width(1);
$line_sma10->set_colour("#DEA325");
$line_sma10->set_key("SMA10", 12);
$line_sma5_default_dot = new dot();
$line_sma5_default_dot->colour('#16AAAF');
$line_sma5 = new line();
$line_sma5->set_default_dot_style($line_sma5_default_dot);
$line_sma5->set_values($sma5);
$line_sma5->set_width(1);
$line_sma5->set_colour("#16AAAF");
$line_sma5->set_key("SMA5", 12);
//print_r($data);
//echo "<br /><br />";
$data = array_reverse($data);
//print_r($data);
$candle = new candle('#134871');
//9933CC
$candle->set_values($data);
$candle->set_tooltip('#x_label#<br>High: #high#<br>Open: #open#<br>Close: #close#<br>Low: #low#');
예제 #8
0
파일: all.php 프로젝트: rb-ma/myaarth
 while ($portfolio_id == $total_data[$i]->portfolio_id) {
     $val = $total_data[$i]->last_change;
     $val2 = $total_data[$i]->sofyr_return;
     $val3 = $total_data[$i]->first_return;
     $amt = $total_data[$i]->amount;
     $year = $data_item->year;
     $month = $data_item->month;
     $day = $data_item->day;
     if ($total_data[$i]->amount > $max) {
         $max = $total_data[$i]->amount;
     }
     if ($total_data[$i]->amount < $min) {
         $min = $total_data[$i]->amount;
     }
     if ($amt_count % $amt_stride == 0) {
         $dot = new dot($amt);
         if ($val > 0.0) {
             $values[array_search($total_data[$i]->symbol_name, $stocks)] = $dot->colour('#006600')->tooltip("{$month}/{$day}/{$year}\n{$amt}\nDay's Return: {$val}%\nYTD Return: {$val2}%\nReturn (Inception): {$val3}%");
         } else {
             $values[array_search($total_data[$i]->symbol_name, $stocks)] = $dot->colour('#FF0000')->tooltip("{$month}/{$day}/{$year}\n{$amt}\nDay's Return: {$val}%\nYTD Return: {$val2}%\nReturn (Inception): {$val3}%");
         }
     }
     $amt_count++;
     $i++;
     $num_updated++;
 }
 $num_portfolios_processed++;
 if ($num_updated != count($stocks) && $amt_count % $amt_stride == 0) {
     // somebody did not have data for a given portfolio_id
     for ($j = 0; $j < count($stocks); $j++) {
         if (count($values[$j]) != $num_portfolios_processed) {
예제 #9
0
function render_service_reports()
{
    $content = "<h1>Service Reports</h1>";
    // Start Filter for  service type
    $allServiceTypes = ServiceType::get_service_types();
    #	$allServiceTypes = array('all' => 'all');
    #$allServiceTypes = array_merge($allServiceTypes, ServiceType::get_service_types());
    $allServiceTypes['all'] = 'all';
    $service_type = $_GET['service_type'];
    $service_filter = $_GET['service_type'];
    if ($service_type == '' || !isset($service_type) || !is_numeric($service_type)) {
        $service_type = 'all';
        $service_filter = '';
    }
    $filter = "\r\n\t\t<FORM>\r\n\t\t<DIV style=\" \">\r\n\t\t<SELECT name'=service_type_report'\r\n\t\t\tonChange=\"window.location='services.php?&action=serviceReports&service_type='+this.options[this.selectedIndex].value;\">";
    foreach ($allServiceTypes as $id => $name) {
        if ($service_type == $id) {
            $selected = "SELECTED";
        } else {
            $selected = '';
        }
        $filter .= "<OPTION value='{$id}' {$selected}>{$name}\n";
    }
    $filter .= "\r\n\t\t</SELECT>\r\n\t\t</DIV>\r\n\t\t</FORM>\r\n\t";
    // End filter
    $max_date = strtotime("2009-01-01");
    $start_date = date("Y-m") . "-01";
    // Get all months since start
    $workdate = strtotime($start_date);
    $now = strtotime("Now");
    $form = new Form(auto, 3);
    $headings = array("Period", "In production", "Out of Production");
    $data = array();
    $x_ax_data = array();
    $y_ax_data = array();
    $handlers = array();
    while ($workdate > $max_date) {
        $sql_enddate = date("Y-m-d", $workdate);
        $month_period = date("m-Y", $workdate);
        // This is for the chart
        $month_label = date("M\nY", $workdate);
        $graph_date = strtotime("-1 month", $workdate);
        $month_label = date("M\nY", $graph_date);
        $sql_startdate = date("Y-m-d", $workdate);
        array_push($x_ax_data, $month_label);
        array_push($y_ax_data, count(Service::get_inprod_services_at_date($sql_startdate, $service_filter)));
        // Add one month
        $workdate = strtotime("-1 month", $workdate);
        $sql_startdate = date("Y-m-d", $workdate);
        $out_of_prod = count(Service::get_outprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        $in_prod = count(Service::get_inprod_services_diff_date($sql_startdate, $sql_enddate, $service_filter));
        array_push($data, "{$sql_startdate} {$sql_enddate}");
        array_push($data, $in_prod);
        array_push($data, $out_of_prod);
        array_push($handlers, "handleEvent('services.php?action=detailedServiceReports&start_date={$sql_startdate}&end_date={$sql_enddate}&service_type={$service_type}')");
    }
    $form->setTableWidth("224px");
    $form->setData($data);
    $form->setEventHandler($handlers);
    $form->setHeadings($headings);
    $form->setSortable(true);
    $content .= "<div style=\"float: left; clear: both; margin-right:28px\">" . $form->showForm() . "</div>";
    // Chart
    //
    // This is the MODEL section:
    //
    include 'open-flash-chart/php-ofc-library/open-flash-chart.php';
    // create an X Axis object
    //
    $y_ax_data = array_reverse($y_ax_data);
    $x_ax_data = array_reverse($x_ax_data);
    $x = new x_axis();
    $x->set_steps(3);
    $x->set_labels_from_array($x_ax_data);
    $max = max($y_ax_data);
    $y = new y_axis();
    $y->set_range(0, $max);
    // Bar
    $bar = new bar();
    $bar->set_values($y_ax_data);
    // Bar
    // ------- LINE 2 -----
    $line_2_default_dot = new dot();
    $line_2_default_dot->size(3)->halo_size(1)->colour('#3D5C56');
    $line_2 = new line();
    $line_2->set_default_dot_style($line_2_default_dot);
    $line_2->set_values($y_ax_data);
    $line_2->set_width(3);
    $line_2->set_colour('#3D5C56');
    $chart = new open_flash_chart();
    $title = new title("In Production Services over Time");
    $title->set_style("{font-size: 10px; font-family: Times New Roman; font-weight: bold; color: #000; text-align: center;}");
    $chart->set_bg_colour('#FFFFFF');
    $chart->set_title($title);
    $chart->add_element($bar);
    //$chart->add_element( $line1 );
    $chart->add_element($line_2);
    $chart->set_x_axis($x);
    $chart->set_y_axis($y);
    //
    // This is the VIEW section:
    // Should print this first.
    //
    $heading = "\r\n\t<script type='text/javascript' src='open-flash-chart/js/json/json2.js'></script>\r\n\t<script type='text/javascript' src='open-flash-chart/js/swfobject.js'></script>\r\n\t<script type='text/javascript'>\r\n\tswfobject.embedSWF('open-flash-chart/open-flash-chart.swf', 'my_chart', '660', '350', '9.0.0');\r\n\t</script>\r\n\r\n\t<script type='text/javascript'>\r\n\r\n\tfunction open_flash_chart_data() {\r\n\t\treturn JSON.stringify(data);\r\n\t}\r\n\r\n\tfunction findSWF(movieName) {\r\n  \t\tif (navigator.appName.indexOf('Microsoft')!= -1) {\r\n    \t\t\treturn window[movieName];\r\n  \t\t} else {\r\n    \t\t\treturn document[movieName];\r\n  \t\t}\r\n\t}\r\n    \r\n\tvar data = " . $chart->toPrettyString() . "\r\n\r\n\t</script>\r\n\r\n\r\n\t<script type=\"text/javascript\">\r\n \r\n\tOFC = {};\r\n \r\n\tOFC.jquery = {\r\n    \tname: 'jQuery',\r\n    \tversion: function(src) { return \$('#'+ src)[0].get_version() },\r\n    \trasterize: function (src, dst) { \$('#'+ dst).replaceWith(OFC.jquery.image(src)) },\r\n    \timage: function(src) { return \"<img src='data:image/png;base64,\" + \$('#'+src)[0].get_img_binary() + \"' />\"},\r\n    \tpopup: function(src) {\r\n        var img_win = window.open('', 'Charts: Export as Image')\r\n        with(img_win.document) {\r\n            write('<html><head><title>Charts: Export as Image<\\/title><\\/head><body>' + OFC.jquery.image(src) + '<\\/body><\\/html>') }\r\n\t\t// stop the 'loading...' message\r\n\t\timg_win.document.close();\r\n     \t}\r\n\t}\r\n \r\n\t// Using_ an object as namespaces is JS Best Practice. I like the Control.XXX style.\r\n\t//if (!Control) {var Control = {}}\r\n\t//if (typeof(Control == \"undefined\")) {var Control = {}}\r\n\tif (typeof(Control == \"undefined\")) {var Control = {OFC: OFC.jquery}}\r\n \r\n \r\n\t// By default, right-clicking on OFC and choosing \"save image locally\" calls this function.\r\n\t// You are free to change the code in OFC and call my wrapper (Control.OFC.your_favorite_save_method)\r\n\t// function save_image() { alert(1); Control.OFC.popup('my_chart') }\r\n\tfunction save_image() { alert(\"Your image will be displayed in a new window\"); OFC.jquery.popup('my_chart') }\r\n\t</script>\r\n\t<div id='my_chart' style='float:left; margin-left:28px;'></div>\r\n\t";
    print " {$content}\n \r\n\t\t<div style=''<b>Select Service Type:</b>{$filter} <br></div>\n\r\n\t\t{$heading} ";
}
예제 #10
0
 // Absisses
 $x = new x_axis();
 //$x->set_labels( $x_labels );
 $x->set_stroke(2);
 $x->set_tick_height(2);
 $x->set_colour("#d000d0");
 $x->set_labels($labels);
 // Nouveau grAphique
 $chart = new open_flash_chart();
 $title = new title("Classement General");
 $chart->set_title($title);
 $chart->set_y_axis($y);
 $chart->set_x_axis($x);
 //$posy=0;
 for ($j = 0; $j < sizeof($listeJoueurs); $j++) {
     $type = new dot();
     // if      ($posy==0)    $type = new dot();
     // else if ($posy==1)    $type = new solid_dot();
     // else if ($posy==2)    $type = new hollow_dot();
     // else if ($posy==3)    $type = new star();
     // else if ($posy==4)    $type = new anchor();
     // else if ($posy==5)    $type = new bow();
     $type->tooltip($listeJoueurs[$j]['nom'] . "<br>Jeu:#x_label#<br>Moy. #val#");
     $line = new line();
     $line->set_default_dot_style($type);
     $line->set_width(1);
     $line->set_colour($G_MesCouleurs[$j]);
     $line->set_values($data_val[$j]);
     $line->set_key($listeJoueurs[$j]["nom"], 10);
     $chart->add_element($line);
     //$posy=$posy+1;
예제 #11
0
function siremis_get_chart_data($groupId, $chartId, $debug = 0)
{
    global $g_BizSystem;
    $cgobj = $g_BizSystem->GetService("ser.service.siremisCharts");
    $cgrp = $cgobj->GetChartGroup($groupId);
    if ($debug == 1) {
        echo "Chart found {$id} :: " . $cgobj->GetChartGroupCount() . " ::: ";
    }
    $chart = $cgrp->GetChart($chartId);
    if (!$chart) {
        echo "Chart not found {$id}\n";
        exit;
    }
    if ($debug == 1) {
        echo "Chart :: " . $cgrp->GetChartCount() . " ::: ";
    }
    $sql = "SELECT * ";
    $xydata = array();
    // XAxis
    $xax = $chart->GetXAxisList();
    foreach ($xax as $it) {
        $sql = "SELECT " . $it->GetXYData();
        $xydata[0] = $it;
    }
    // YAxis
    $yax = $chart->GetYAxisList();
    $yn = 0;
    foreach ($yax as $it) {
        $sql .= "," . $it->GetXYData();
        $yn = $yn + 1;
        $xydata[$yn] = $it;
    }
    if ($debug == 1) {
        echo "::::::: {$yn} ::: " . $chart->GetYAxisCount();
    }
    $sql .= " FROM " . $chart->GetTable();
    if ($chart->GetOrderBy() && $chart->GetOrderBy() != "") {
        $sql .= " " . $chart->GetOrderBy();
    }
    if ($chart->GetLimit() && $chart->GetLimit() != "") {
        $sql .= " " . $chart->GetLimit();
    }
    // " ORDER BY id DESC LIMIT 30";
    $db = $g_BizSystem->GetDBConnection("Serdb");
    $resultSet = $db->query($sql);
    if ($resultSet === false) {
        $err = $db->ErrorMsg();
        echo $err;
        exit;
    }
    $xdata = array();
    $ydata = array();
    for ($i = 0; $i < $yn; $i = $i + 1) {
        $ydata[$i] = array();
    }
    $k = 0;
    $ymin = 0;
    $ymax = 0;
    while ($row = $resultSet->fetch()) {
        $xdata[$k] = $row[0];
        for ($i = 0; $i < $yn; $i = $i + 1) {
            $ydata[$i][$k] = 0 + $row[$i + 1];
            if ($k == 0) {
                $ymin = $ydata[$i][$k];
                $ymax = $ydata[$i][$k];
            } else {
                if ($ydata[$i][$k] < $ymin) {
                    $ymin = $ydata[$i][$k];
                }
                if ($ydata[$i][$k] > $ymax) {
                    $ymax = $ydata[$i][$k];
                }
            }
        }
        $k = $k + 1;
    }
    $ofcobj = new open_flash_chart();
    $ctitle = $chart->GetTitle();
    $rev = 0;
    if ($chart->GetOrder() && $chart->GetOrder() == "reverse") {
        $rev = 1;
    }
    $x = new x_axis();
    $xstep = (int) ($k / 20);
    if ($k % 20 != 0) {
        $xstep = $xstep + 1;
    }
    $x->set_steps($xstep);
    if ($xydata[0]->getXYType() == "timestamp") {
        if ($rev == 1) {
            $time_min = $xdata[$k - 1];
            $time_max = $xdata[0];
        } else {
            $time_min = $xdata[0];
            $time_max = $xdata[$k - 1];
        }
        $ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
        $ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
        $time_x_labels = new x_axis_labels();
        $time_x_labels->rotate(20);
        $chart_lbls = array();
        for ($i = 0; $i < $k; $i = $i + 1) {
            if ($rev == 0) {
                $chart_lbls[] = date('H:i', $xdata[$i]);
            } else {
                $chart_lbls[] = date('H:i', $xdata[$k - $i - 1]);
            }
        }
        $time_x_labels->visible_steps($xstep);
        $time_x_labels->set_labels($chart_lbls);
        $x->set_labels($time_x_labels);
    } else {
        $time_x_labels->visible_steps($xstep);
        if ($rev == 1) {
            $ctitle .= " - From " . $xdata[$k - 1] . " To " . $xdata[0];
        } else {
            $ctitle .= " - From " . $xdata[0] . " To " . $xdata[$k - 1];
        }
    }
    $ofcobj->set_title(new title($ctitle));
    $dot_style = new dot();
    $dot_style->size(3)->halo_size(1);
    for ($i = 0; $i < $yn; $i++) {
        if ($chart->GetChartType() == "area") {
            $line[$i] = new area();
            $line[$i]->set_fill_alpha(0.3);
            $line[$i]->set_default_dot_style($dot_style);
        } else {
            if ($chart->GetChartType() == "line_dot") {
                $line[$i] = new line_dot();
                $line[$i]->set_default_dot_style($dot_style);
            } else {
                $line[$i] = new line();
                $line[$i]->set_default_dot_style($dot_style);
            }
        }
        if ($xydata[$i + 1]->GetXYColor() && $xydata[$i + 1]->GetXYColor() != "") {
            $line[$i]->set_colour($xydata[$i + 1]->GetXYColor());
        }
        if ($xydata[$i + 1]->GetXYTitle() && $xydata[$i + 1]->GetXYTitle() != "") {
            $line[$i]->set_key($xydata[$i + 1]->GetXYTitle(), 10);
        } else {
            $line[$i]->set_key("Key " . $i, 10);
        }
        if ($rev == 1) {
            $line[$i]->set_values(array_reverse($ydata[$i]));
        } else {
            $line[$i]->set_values($ydata[$i]);
        }
        $ofcobj->add_element($line[$i]);
    }
    if ($ymax > 10) {
        $y = new y_axis();
        if ($ymin > 10) {
            $y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
        } else {
            $y->set_range(0, $ymax, (int) ($ymax / 10));
        }
        $ofcobj->set_y_axis($y);
    }
    $ofcobj->set_x_axis($x);
    if ($chart->GetBGColor() && $chart->GetBGColor() != "") {
        $ofcobj->set_bg_colour($chart->GetBGColor());
    }
    // return $ofcobj->toPrettyString();
    return $ofcobj->toString();
}
 function get_daily_entries($form, $colors = false, $type = "DATE")
 {
     global $wpdb, $frmdb;
     if (!$colors) {
         $colors = array('#EF8C08', '#21759B', '#1C9E05');
     }
     $type = strtoupper($type);
     //Chart for Entries Submitted
     $values = array();
     $labels = array();
     if ($type == 'HOUR') {
         $start_timestamp = strtotime('-48 hours');
     } else {
         if ($type == 'MONTH') {
             $start_timestamp = strtotime('-1 year');
         } else {
             if ($type == 'YEAR') {
                 $start_timestamp = strtotime('-10 years');
             } else {
                 $start_timestamp = strtotime('-1 month');
             }
         }
     }
     $end_timestamp = time();
     if ($type == 'HOUR') {
         $query = "SELECT en.created_at as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j H", $start_timestamp) . ":00:00' AND en.form_id={$form->id} GROUP BY endate";
     } else {
         $query = "SELECT DATE(en.created_at) as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j", $start_timestamp) . " 00:00:00' AND en.form_id={$form->id} GROUP BY {$type}(en.created_at)";
     }
     $entries_array = $wpdb->get_results($query);
     $temp_array = $counts_array = $dates_array = array();
     // Refactor Array for use later on
     foreach ($entries_array as $e) {
         $e_key = $e->endate;
         if ($type == 'HOUR') {
             $e_key = date('Y-m-d H', strtotime($e->endate)) . ':00:00';
         } else {
             if ($type == 'MONTH') {
                 $e_key = date('Y-m', strtotime($e->endate)) . '-01';
             } else {
                 if ($type == 'YEAR') {
                     $e_key = date('Y', strtotime($e->endate)) . '-01-01';
                 }
             }
         }
         $temp_array[$e_key] = $e->encount;
     }
     // Get the dates array
     if ($type == 'HOUR') {
         for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60) {
             if (!in_array(date('Y-m-d H', $e) . ':00:00', $dates_array)) {
                 $dates_array[] = date('Y-m-d H', $e) . ':00:00';
             }
         }
         $date_format = get_option('time_format');
     } else {
         if ($type == 'MONTH') {
             for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 25) {
                 if (!in_array(date('Y-m', $e) . '-01', $dates_array)) {
                     $dates_array[] = date('Y-m', $e) . '-01';
                 }
             }
             $date_format = 'F Y';
         } else {
             if ($type == 'YEAR') {
                 for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 364) {
                     if (!in_array(date('Y', $e) . '-01-01', $dates_array)) {
                         $dates_array[] = date('Y', $e) . '-01-01';
                     }
                 }
                 $date_format = 'Y';
             } else {
                 for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24) {
                     $dates_array[] = date("Y-m-d", $e);
                 }
                 $date_format = get_option('date_format');
             }
         }
     }
     // Make sure counts array is in order and includes zero click days
     foreach ($dates_array as $date_str) {
         if (isset($temp_array[$date_str])) {
             $counts_array[$date_str] = $temp_array[$date_str];
         } else {
             $counts_array[$date_str] = 0;
         }
     }
     foreach ($counts_array as $date => $count) {
         $labels[] = date_i18n($date_format, strtotime($date));
         $values[] = (int) $count;
     }
     if ($type == 'MONTH') {
         $title = __('Monthly Entries', 'formidable');
     } else {
         if ($type == 'YEAR') {
             $title = __('Yearly Entries', 'formidable');
         } else {
             if ($type == 'HOUR') {
                 $title = __('Hourly Entries', 'formidable');
             } else {
                 $title = __('Daily Entries', 'formidable');
             }
         }
     }
     $title = new title($title);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour($colors[0]);
     $line_1_default_dot->tooltip('#x_label#<br>#val# Entries');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($values);
     $line_1->set_colour($colors[1]);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->set_bg_colour('#FFFFFF');
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->rotate(340);
     $x_labels->set_labels($labels);
     if (count($labels) > 15) {
         $x_labels->visible_steps(2);
     }
     $x->set_labels($x_labels);
     $chart->set_x_axis($x);
     $y = new y_axis();
     if (!empty($values)) {
         $max = max($values) + 1;
         $step = ceil($max / 10);
         $y->set_range(0, $max, $step);
     }
     $chart->add_element($line_1);
     $chart->set_y_axis($y);
     return $chart->toPrettyString();
 }
예제 #13
0
    protected function renderHTML()
    {
        global $g_BizSystem;
        include_once MODULE_PATH . '/ser/config/cms.ChartsStatsAccCfg.php';
        $fetchInterval = $cfg_stats_acc_fetch_interval;
        $sql = "SELECT method, sip_code, time, UNIX_TIMESTAMP(time) as tstamp FROM acc WHERE DATE_SUB(NOW(), INTERVAL " . $fetchInterval . " HOUR) <= time";
        $db = $g_BizSystem->GetDBConnection("Serdb");
        $resultSet = $db->query($sql);
        if ($resultSet === false) {
            $err = $db->ErrorMsg();
            echo $err;
            exit;
        }
        $chart_colors = array();
        $chart_colors[0] = '#FF0000';
        $chart_colors[1] = '#00FF00';
        $chart_colors[2] = '#0000FF';
        $chart_colors[3] = '#408080';
        $chart_colors[4] = '#330000';
        $chart_colors[5] = '#FDD017';
        $chart_colors[6] = '#52D017';
        $chart_colors[7] = '#6698FF';
        $chart_colors[8] = '#00FFFF';
        $chart_colors[9] = '#FF00FF';
        $chart_colors[10] = '#2554C7';
        $chart_colors[11] = '#806D7E';
        $chart_colors[12] = '#FF8040';
        $chart_colors[13] = '#C0C0C0';
        $chart_colors[14] = '#808000';
        $chart_colors[15] = '#800000';
        $chart_colors_size = 16;
        $acc_records = array();
        $acc_records['invite'] = array();
        $acc_records['bye'] = array();
        $acc_records['message'] = array();
        $acc_records['other'] = array();
        $acc_records['invite200'] = array();
        $acc_records['invite404'] = array();
        $acc_records['invite487'] = array();
        $acc_records['inviteXYZ'] = array();
        for ($i = 0; $i <= $fetchInterval; $i++) {
            $acc_records['invite'][$i] = 0;
            $acc_records['bye'][$i] = 0;
            $acc_records['message'][$i] = 0;
            $acc_records['other'][$i] = 0;
            $acc_records['invite200'][$i] = 0;
            $acc_records['invite404'][$i] = 0;
            $acc_records['invite487'][$i] = 0;
            $acc_records['inviteXYZ'][$i] = 0;
        }
        $ymax = 0;
        $ymin = 0xfffffff;
        $yidx = 0;
        $ousr = 0;
        $ctime = time();
        $stime = $ctime - 3600 * $fetchInterval;
        while ($row = $resultSet->fetch()) {
            $r_method = $row[0];
            $r_sip_code = $row[1];
            $r_time = $row[2];
            $r_tstamp = $row[3];
            $idx = (int) (($r_tstamp - $stime) / 3600);
            /* method stats */
            if (isset($r_method)) {
                if ($r_method == "INVITE") {
                    $acc_records['invite'][$idx] = $acc_records['invite'][$idx] + 1;
                    if ($r_sip_code == "200") {
                        $acc_records['invite200'][$idx] = $acc_records['invite200'][$idx] + 1;
                    } else {
                        if ($r_sip_code == "404") {
                            $acc_records['invite404'][$idx] = $acc_records['invite404'][$idx] + 1;
                        } else {
                            if ($r_sip_code == "487") {
                                $acc_records['invite487'][$idx] = $acc_records['invite487'][$idx] + 1;
                            } else {
                                $acc_records['inviteXYZ'][$idx] = $acc_records['inviteXYZ'][$idx] + 1;
                            }
                        }
                    }
                } else {
                    if ($r_method == "BYE") {
                        $acc_records['bye'][$idx] = $acc_records['bye'][$idx] + 1;
                    } else {
                        if ($r_method == "MESSAGE") {
                            $acc_records['message'][$idx] = $acc_records['message'][$idx] + 1;
                        } else {
                            $acc_records['other'][$idx] = $acc_records['other'][$idx] + 1;
                        }
                    }
                }
            }
            $yidx = $yidx + 1;
        }
        /* sip method types chart */
        $mtsobj = new open_flash_chart();
        $ctitle = "SIP Method Types";
        $x = new x_axis();
        $xstep = (int) ($fetchInterval / 12);
        if ($fetchInterval % 2 != 0) {
            $xstep = $xstep + 1;
        }
        $x->set_steps($xstep);
        $time_min = $stime;
        $time_max = $ctime;
        $ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
        $ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
        $time_x_labels = new x_axis_labels();
        $time_x_labels->rotate(20);
        $chart_lbls = array();
        for ($i = 0; $i < $fetchInterval; $i = $i + 1) {
            $chart_lbls[] = date('H:i', $stime + 3600 * $i);
        }
        $time_x_labels->visible_steps($xstep);
        $time_x_labels->set_labels($chart_lbls);
        $x->set_labels($time_x_labels);
        $mtsobj->set_title(new title($ctitle));
        $dot_style = new dot();
        $dot_style->size(3)->halo_size(1);
        $clr = 0;
        $i = 0;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("INVITE", 10);
        $line[$i]->set_values($acc_records['invite']);
        $mtsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("BYE", 10);
        $line[$i]->set_values($acc_records['bye']);
        $mtsobj->add_element($line[$i]);
        $i++;
        if ($cfg_stats_acc_message) {
            $line[$i] = new line();
            $line[$i]->set_default_dot_style($dot_style);
            $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
            $line[$i]->set_key("MESSAGE", 10);
            $line[$i]->set_values($acc_records['message']);
            $mtsobj->add_element($line[$i]);
            $i++;
        }
        if ($cfg_stats_acc_other) {
            $line[$i] = new line();
            $line[$i]->set_default_dot_style($dot_style);
            $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
            $line[$i]->set_key("OTHER", 10);
            $line[$i]->set_values($acc_records['other']);
            $mtsobj->add_element($line[$i]);
            $i++;
        }
        $val = max($acc_records['invite']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['bye']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        if ($cfg_stats_acc_message) {
            $val = max($acc_records['message']);
            if ($ymax < $val) {
                $ymax = $val;
            }
        }
        if ($cfg_stats_acc_other) {
            $val = max($acc_records['other']);
            if ($ymax < $val) {
                $ymax = $val;
            }
        }
        $val = min($acc_records['invite']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['bye']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        if ($cfg_stats_acc_message) {
            $val = min($acc_records['message']);
            if ($ymin > $val) {
                $ymin = $val;
            }
        }
        if ($cfg_stats_acc_other) {
            $val = min($acc_records['other']);
            if ($ymin > $val) {
                $ymin = $val;
            }
        }
        if ($ymax > 10) {
            $y = new y_axis();
            if ($ymin > 10) {
                $y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
            } else {
                $y->set_range(0, $ymax, (int) ($ymax / 10));
            }
            $mtsobj->set_y_axis($y);
        }
        $mtsobj->set_x_axis($x);
        $mtsobj->set_bg_colour("#A0C0B0");
        /* sip invites chart */
        $ivsobj = new open_flash_chart();
        $ctitle = "SIP INVITEs";
        $ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
        $ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
        $ivsobj->set_title(new title($ctitle));
        $ymax = 0;
        $ymin = 0xfffffff;
        $i = 0;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("200", 10);
        $line[$i]->set_values($acc_records['invite200']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("404", 10);
        $line[$i]->set_values($acc_records['invite404']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("487", 10);
        $line[$i]->set_values($acc_records['invite487']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("XYZ", 10);
        $line[$i]->set_values($acc_records['inviteXYZ']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $val = max($acc_records['invite200']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['invite404']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['invite487']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['inviteXYZ']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = min($acc_records['invite200']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['invite404']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['invite487']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['inviteXYZ']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        if ($ymax > 10) {
            $y = new y_axis();
            if ($ymin > 10) {
                $y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
            } else {
                $y->set_range(0, $ymax, (int) ($ymax / 10));
            }
            $ivsobj->set_y_axis($y);
        }
        $ivsobj->set_x_axis($x);
        $ivsobj->set_bg_colour("#C0C0A0");
        $sHTML = '';
        $sHTML .= '
			<div align="center">
				<p><b>Processed ' . $yidx . ' records. <br />Timezone: ' . date_default_timezone_get() . ' </b></p>
			</div>
			';
        if ($yidx > 0) {
            $sHTML .= '
			<script type="text/javascript" src="' . APP_URL . '/js/swfobject.js"></script>
			<script type="text/javascript">
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_acc_methods",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_acc_methods"} );
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_acc_invites",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_acc_invites"} );
			</script> 
			';
            $sHTML .= '
			<br />
			<div align="center">
				<div id="div_chart_acc_methods">
				</div>
				<br />
				<br />
				<div id="div_chart_acc_invites">
				</div>
				<br />
				<br />
			</div>
			';
            $sHTML .= '
			<script type="text/javascript">
				function get_data_acc_methods()
				{
					data = \'' . $mtsobj->toString() . '\';
					return data;
				}
				function get_data_acc_invites()
				{
					data = \'' . $ivsobj->toString() . '\';
					return data;
				}
			</script>
			';
        }
        /* if $yidx */
        return $sHTML;
    }
예제 #14
0
include 'include.php';
$this_month = ' -w -J --forecast "d<=[today]+365" -d "d>=[next month] & d<=[today]+365" --sort d reg FirstTech:Checking';
exec("{$ledger} {$this_month}", $output);
foreach ($output as $line) {
    $tmp = explode(" ", $line);
    $datalist[] = 1 * $tmp[1];
    $labellist[] = $tmp[0];
}
//Prevent error on no data
if (count($datalist < 1)) {
    $datalist[] = 0;
    $labellist[] = 0;
}
$title = new title("Checking account forecast");
$default_dot = new dot();
$default_dot->tooltip('$#val#');
$line = new line();
$line->set_values($datalist);
$line->set_default_dot_style($default_dot);
$x_labels = new x_axis_labels();
$x_labels->rotate(45);
$x_labels->set_labels($labellist);
$x_labels->set_steps(3);
$x = new x_axis();
$x->set_labels($x_labels);
$y = new y_axis();
$y->set_range(min(min($datalist) - 10, 0), round(max($datalist) * 1.1));
$y->set_label_text("\$#val#");
$chart = new open_flash_chart();
$chart->set_title($title);
예제 #15
0
         $max = $tmp[1];
     }
     if ($tmp[1] < $min) {
         $min = $tmp[1];
     }
 }
 sort($labellist);
 $title = new title($bank . " Retrospective");
 $cdot = new dot();
 $cdot->size(3)->colour("#0000FF")->tooltip('$#val#');
 $cline = new line();
 $cline->set_values($cdatalist);
 $cline->set_colour("#0000FF");
 $cline->set_default_dot_style($cdot);
 $cline->set_key("Checking", 12);
 $sdot = new dot();
 $sdot->size(3)->colour("#FF0000")->tooltip('$#val#');
 $sline = new line();
 $sline->set_values($sdatalist);
 $sline->set_colour("#FF0000");
 $sline->set_default_dot_style($sdot);
 $sline->set_key("Savings", 12);
 $x_labels = new x_axis_labels();
 $x_labels->rotate(45);
 $x_labels->set_labels($labellist);
 $x_labels->set_steps(3);
 $x = new x_axis();
 $x->set_labels($x_labels);
 $y = new y_axis();
 $y->set_range(round($min) * 1.1, round($max) * 1.1);
 $y->set_label_text("\$#val#");
예제 #16
0
 /**
  * Creates new dot for line and area graph
  *
  * @return unknown
  */
 protected function createDot($color = '#f58615', $value = null)
 {
     $dot = new dot($value);
     $dot->colour($color)->size(4);
     return $dot;
 }
예제 #17
0
 public function clientimpressionAction()
 {
     ini_set('display_errors', 1);
     $frontController = Zend_Controller_Front::getInstance();
     $frontController->throwExceptions(true);
     // filter!
     if (!$this->clientdashboardfilter()) {
         return;
     }
     $this->view->activeTab = 'clientimpression';
     include 'open-flash-chart.php';
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $campaign_id = $formData['campaign_id'];
     } else {
         $campaign_id = $request->getParam('id');
     }
     $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign_id));
     $this->view->campaign_id = $campaign_id;
     // get date from db
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('report', array('left(create_date,10) as date', 'accesscode'))->where('report.campaign_id = ?', $campaign_id)->where('report.state = "APPROVED"')->order('date');
     $results = $db->fetchAll($select);
     $accesscodeDbMatchArray = array();
     foreach ($results as $result) {
         $accesscodeDbMatchArray[$result['accesscode']] = $result['date'];
     }
     $accesscodeArray = array_keys($accesscodeDbMatchArray);
     $campaignModel = new Campaign();
     $campaign = $campaignModel->fetchRow('id = ' . $campaign_id);
     // get impression value from ws
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('dashboard_mapping');
     $select->where('survey_id = ?', $campaign->i2_survey_id);
     $select->where('mark="FRIENDS"');
     $mappings = $db->fetchRow($select);
     $indicate2Connect = new Indicate2_Connect();
     $response = $indicate2Connect->getAnswerSetForSurvey(array($campaign->i2_survey_id, $campaign->i2_survey_id_en), null, array(array('ContextIndex' => $mappings['context_index'], 'QuestionIndex' => $mappings['question_index'])), 0);
     //        Zend_Debug::dump($mappings);die;
     $optionArray = array();
     if (isset($response->QuestionType) && is_array($response->QuestionType)) {
         foreach ($response->QuestionType as $questionType) {
             foreach ($questionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     } else {
         if (isset($response->QuestionType->SelectionQuestionOptionType)) {
             foreach ($response->QuestionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 if ($optionObject->OptionText == '>=10') {
                     $optionArray[$optionObject->OptionId] = 10;
                 }
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     }
     $answerArray = array();
     $i = 0;
     if (isset($response->AnswerSetType)) {
         foreach ($response->AnswerSetType as $answerObject) {
             $answerArray[$i++] = array($answerObject->AccessCode, iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answerObject->AnswerType->AnswerText))));
         }
     }
     // create x axis date value (endDate = expireDate/now + 10 days)
     $this->view->startDate = $startDate = date("Y-m-d", strtotime($campaign->create_date));
     if (strtotime($campaign->expire_date) > strtotime(date("Y-m-d"))) {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime(date("Y-m-d"))));
     } else {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime($campaign->expire_date)));
     }
     if ($request->isPost()) {
         $formData = $request->getPost();
         $this->view->xmax = $endDate = $formData['x_max'];
     }
     $resultArray = array();
     $xDateArrayLength = 0;
     while (1) {
         $resultArray[$startDate] = 0;
         $startDate = date("Y-m-d", strtotime("+1 days", strtotime($startDate)));
         $xDateArrayLength++;
         if ($startDate == $endDate) {
             $resultArray[$startDate] = 0;
             $xDateArrayLength++;
             break;
         }
     }
     //var_dump($resultArray);die;
     // set sparks initial impressions for each campaign, it should be added if a new campaign is lanuched!
     switch ($campaign_id) {
         case '1':
             $staticsparks = array(50, 110);
             break;
         case '2':
             $staticsparks = array(50, 150, 250, 400, 450);
             break;
         case '3':
             $staticsparks = array(100, 350, 750, 1200, 1500);
             break;
         case '4':
             $staticsparks = array(50, 200, 250);
             break;
         case '5':
             $staticsparks = array(50, 150);
             break;
         case '6':
             $staticsparks = array(50, 150, 350, 500, 900, 1700, 2300, 2500);
             break;
         case '7':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 150, 350, 500, 900, 1038);
             break;
         case '8':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '9':
             $staticsparks = array(0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '10':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '13':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 50, 100, 150, 300, 450, 600, 750, 900, 1200);
             break;
         default:
             break;
     }
     for ($temp = count($staticsparks); $temp < $xDateArrayLength; $temp++) {
         $staticsparks[$temp] = $staticsparks[$temp - 1];
     }
     // set everyday impression by using ws data
     foreach ($answerArray as $answer) {
         if (!isset($accesscodeDbMatchArray[$answer[0]])) {
             continue;
         }
         if (date("Y-m-d", strtotime($accesscodeDbMatchArray[$answer[0]])) > date("Y-m-d", strtotime($this->view->xmax))) {
             continue;
         }
         if (!array_key_exists($accesscodeDbMatchArray[$answer[0]], $resultArray)) {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] = $optionArray[$answer[1]];
         } else {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] += $optionArray[$answer[1]];
         }
     }
     //Zend_Debug::dump($optionArray);
     //Zend_Debug::dump($resultArray);
     //Zend_Debug::dump($answerArray);
     //Zend_Debug::dump($accesscodeDbMatchArray);
     // set line value
     $sparks = 0;
     $data_1 = array();
     $data_2min = array();
     $data_2max = array();
     $data_3min = array();
     $data_3max = array();
     $i = 0;
     $data_1[0] = $data_2max[0] = $data_2min[0] = $data_3min[0] = $data_3max[0] = $accumulate = 0;
     $temp = 0;
     foreach ($resultArray as $result) {
         if ($result != 0) {
             $xTodayLength = $temp;
         }
         $temp++;
     }
     foreach ($resultArray as $result) {
         if ($i == 0) {
             $i++;
             continue;
         }
         $accumulate = $result + $accumulate;
         $data_1[$i] = $accumulate + $staticsparks[$i];
         $data_2min[$i] = floor($accumulate * 2.5 + $staticsparks[$i]);
         $data_2max[$i] = $accumulate * 5 + $staticsparks[$i];
         $data_2avg[$i] = $accumulate * 3.75;
         $data_3min[$i] = floor($data_2avg[$i] * 3) + $data_2min[$i];
         $data_3max[$i] = floor($data_2avg[$i] * 4) + $data_2max[$i];
         $max = $data_3max[$i];
         if ($i == $xTodayLength) {
             break;
         }
         $i++;
     }
     // set max y axis value
     $dateArray = array_keys($resultArray);
     $y = new y_axis();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $max = $formData['y_max'];
     } else {
         if ($max < 10000) {
             $max = ceil($max / 100) * 100;
         } else {
             $max = ceil($max / 1000) * 1000;
         }
     }
     $y->set_range(0, $max, $max / 10);
     $this->view->ymax = $max;
     // draw lines
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($dateArray);
     $x_labels->set_steps(floor($xDateArrayLength / 42) + 1);
     $x_labels->rotate(40);
     $x->set_labels($x_labels);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour('#007DCD')->tooltip('#x_label#: #val#');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($data_1);
     $line_1->set_colour("#007DCD");
     $line_1->set_width(1);
     $line_2min_default_dot = new dot();
     $line_2min_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2min = new line();
     $line_2min->set_default_dot_style($line_2min_default_dot);
     $line_2min->set_values($data_2min);
     $line_2min->set_colour("#81C909");
     $line_2min->set_width(1);
     $line_2_default_dot = new dot();
     $line_2_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2 = new line();
     $line_2->set_default_dot_style($line_2_default_dot);
     $line_2->set_values($data_2max);
     $line_2->set_colour("#81C909");
     $line_2->set_width(1);
     $line_3_default_dot = new dot();
     $line_3_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3 = new line();
     $line_3->set_default_dot_style($line_3_default_dot);
     $line_3->set_values($data_3min);
     $line_3->set_colour("#FF0000");
     $line_3->set_width(1);
     $line_3max_default_dot = new dot();
     $line_3max_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3max = new line();
     $line_3max->set_default_dot_style($line_3max_default_dot);
     $line_3max->set_values($data_3max);
     $line_3max->set_colour("#FF0000");
     $line_3max->set_width(1);
     //tags
     $tags = new ofc_tags();
     $tags->font("Verdana", 10)->colour("#2F2F2F")->align_x_right();
     $this->view->chart = new open_flash_chart();
     // create event
     $campaignEventModel = new CampaignEvent();
     $campaignEvents = $campaignEventModel->fetchAll('campaign_id = ' . $campaign_id, 'event_date');
     $eventTotal = count($campaignEvents);
     $eventTemp = 0;
     foreach ($campaignEvents as $campaignEvent) {
         $eventDate = floor((strtotime($campaignEvent->event_date) - strtotime($campaign->create_date)) / 86400);
         $eventDescription = $campaignEvent->event_name;
         // event line
         $eventline = new scatter_line('#C5BE97', 1);
         $def = new hollow_dot();
         $def->size(0)->halo_size(0);
         $eventline->set_default_dot_style($def);
         $v = array(new scatter_value($eventDate, 0), new scatter_value($eventDate, $this->view->ymax));
         $eventline->set_values($v);
         $this->view->chart->add_element($eventline);
         // event description
         $tagAndArrow_Yvalue = 1 - ($eventTotal - $eventTemp++) / 10;
         if ($tagAndArrow_Yvalue == 0) {
             $tagAndArrow_Yvalue = 0.1;
         }
         $tag_xvalue = $eventDate + 2;
         $t = new ofc_tag($tag_xvalue, $this->view->ymax * $tagAndArrow_Yvalue);
         $t->text($eventDescription)->style(false, false, false, 1.0)->padding(0, 0);
         $tags->append_tag($t);
         // event arrow
         $arrowStart_x = $tag_xvalue;
         $arrowStart_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowEnd_x = $tag_xvalue - 1.5;
         $arrowEnd_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowColor = '#000000';
         $arrowBarbLength = 7;
         $a = new ofc_arrow($arrowStart_x, $arrowStart_y, $arrowEnd_x, $arrowEnd_y, $arrowColor, $arrowBarbLength);
         $this->view->chart->add_element($a);
     }
     $this->view->chart->add_element($line_1);
     $this->view->chart->add_element($line_2min);
     $this->view->chart->add_element($line_2);
     $this->view->chart->add_element($line_3);
     $this->view->chart->add_element($line_3max);
     $this->view->chart->add_element($tags);
     $this->view->chart->set_y_axis($y);
     $this->view->chart->set_x_axis($x);
     $this->view->chart->set_bg_colour('#FFFFFF');
 }