Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1066

Přidáno uživatelem Michal Kliment před více než 13 roky(ů)

Zobrazeni prirustku a ubytku clenu slouceno do jedine funkce a upgradovano na novou verzi Google Chart.

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'debtors' => 'Dlužníci',
'december' => 'Prosinec',
'decision counsil about adoption of member' => 'Rozhodnutí Rady o přijetí člena',
'decrease' => 'Úbytek',
'decrease of members' => 'Úbytek členů',
'deduct' => 'Strhnout',
'deduct entrance fee' => 'Strhnout vstupní příspěvek',
......
'generation of configuration files' => 'Generování konfiguračních souborů',
'good' => 'Dobré',
'gps' => 'GPS souřadnice',
'graph of increase and decrease of members' => 'Graf přírůstku a úbytku členů',
'graph of transmitted data of member' => 'Graf přenesených dat člena',
'group' => 'Skupina',
'group by' => 'Shlukovat',
......
'incomes' => 'Příjmy',
'incoming member payment' => 'Příchozí členské příspěvky',
'incoming member payment in the period' => 'Příchozí členské příspěvky v období',
'increase' => 'Přírůstek',
'increase and decrease of members' => 'Přírůstek a úbytek členů',
'increase of members' => 'Přírůstek členů',
'increased activity' => 'Zvýšená aktivita',
'indefinitely' => 'Na neurčito',
freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml
<input></input>
</values>
</method>
<method name="members_increase" autogenerate="on">
<method name="members_increase_decrease" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="members_decrease" autogenerate="on">
<method name="drawChart" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
......
</input>
</values>
</method>
<method name="show_by_member" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
<attribute name="type" default_value="daily" />
<attribute name="limit_results" default_value="50" />
<attribute name="order_by" default_value="" />
<attribute name="order_by_direction" default_value="ASC" />
<attribute name="page_word" default_value="" />
<attribute name="page" default_value="1" />
</attributes>
<values>
<input>
<param value="" />
<param value="daily" />
<param value="50" />
<param value="" />
<param value="ASC" />
<param value="" />
<param value="1" />
</input>
</values>
</method>
<method name="drawChart" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
</controller>
<controller name="unit_tester">
<method name="unit_tester_exception_handler" autogenerate="off">
......
</input>
</values>
</method>
<method name="get_all_entrance_and_leaving_dates" autogenerate="on">
<attributes>
<attribute name="filter_sql" default_value="" />
</attributes>
<values>
<input>
<param value="" />
</input>
</values>
</method>
</model>
<model name="members_domicile"></model>
<model name="members_fee">
......
</input>
</values>
</method>
<method name="get_today_member_traffic" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
</attributes>
<values>
<input>
<param value="" />
</input>
</values>
</method>
<method name="get_week_member_traffic" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
</attributes>
<values>
<input>
<param value="" />
</input>
</values>
</method>
<method name="get_month_member_traffic" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
</attributes>
<values>
<input>
<param value="" />
</input>
</values>
</method>
<method name="get_member_traffics" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
<attribute name="type" default_value="" />
<attribute name="limit_from" default_value="0" />
<attribute name="limit_results" default_value="50" />
<attribute name="order_by" default_value="" />
<attribute name="order_by_direction" default_value="ASC" />
<attribute name="filter_sql" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="0" />
<param value="50" />
<param value="" />
<param value="ASC" />
<param value="" />
</input>
</values>
</method>
<method name="count_member_traffics" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
<attribute name="type" default_value="" />
<attribute name="filter_sql" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="avg_member_traffics" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
<attribute name="type" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="updates_members_traffics_by_date" autogenerate="off">
<attributes>
<attribute name="date" default_value=""/>
......
</attributes>
<values>
</values>
</method></model>
</method>
</model>
<model name="membership_interrupt">
<method name="has_member_interrupt_in_date" autogenerate="off">
<attributes>
......
<values>
</values>
</method>
<method name="phone_invoice_user_state" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_period_field" autogenerate="off">
<attributes>
<attribute name="item" default_value=""/>
......
</attributes>
<values>
</values>
</method></helper>
</method>
<method name="week_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="month_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
</helper>
<helper name="cookie">
<method name="set" autogenerate="on">
<attributes>
freenetis/branches/testing/application/models/member.php
GROUP BY m.id
", array($segment_id));
}
public function get_all_entrance_and_leaving_dates ($filter_sql = '')
{
$where = '';
if ($filter_sql != '')
$where = "WHERE $filter_sql";
return $this->db->query("
SELECT date AS date, SUM(increase) AS increase, SUM(decrease) AS decrease
FROM
(
SELECT SUBSTR(date,1,7) AS date, SUM(increase) AS increase, SUM(decrease) AS decrease
FROM
(
SELECT entrance_date AS date, COUNT(entrance_date) AS increase, 0 AS decrease
FROM members m
GROUP BY entrance_date
UNION
SELECT leaving_date AS date, 0 AS increase, COUNT(leaving_date) AS decrease
FROM members m
WHERE m.leaving_date IS NOT NULL AND m.leaving_date <> '' AND m.leaving_date <> '0000-00-00'
GROUP BY leaving_date
) m
$where
GROUP BY date
) m
GROUP BY date
ORDER BY date
");
}
}
freenetis/branches/testing/application/controllers/stats.php
function __construct()
{
parent::__construct();
$array[] = html::anchor(url_lang::base().'stats/members_increase',url_lang::lang('texts.Increase of members'));
$array[] = html::anchor(url_lang::base().'stats/members_decrease',url_lang::lang('texts.Decrease of members'));
$array[] = html::anchor(url_lang::base().'stats/members_increase_decrease',url_lang::lang('texts.Increase and decrease of members'));
$array[] = html::anchor(url_lang::base().'stats/members_growth',url_lang::lang('texts.Growth of members'));
$array[] = html::anchor(url_lang::base().'stats/incoming_member_payment',url_lang::lang('texts.Incoming member payment'));
$this->links = implode(' | ',$array);
......
*/
function index()
{
url::redirect(url_lang::base().'stats/members_increase');
url::redirect(url_lang::base().'stats/members_increase_decrease');
}
/**
* Function to show increase of members in each month of being of association
* @author Michal Kliment
*/
function members_increase()
function members_increase_decrease()
{
// access control
if (!$this->acl_check_edit('Settings_Controller','system'))
Controller::error(ACCESS);
// creates new member model
$member_model = new Member_Model();
// finds all members
$members = $member_model->orderby('entrance_date')->find_all();
// creates instance of member ID=1 (Association)
// creates instance of member ID=1 (Association)
$association = new Member_Model(1);
$association_entrance_date = date_parse($association->entrance_date);
$entrances = array();
$max = 0;
foreach ($members as $member)
{
// parses date from datetime to array
$entrance_date = date_parse(date::month($member->entrance_date));
// someone just entranced this month
if (isset($entrances[$entrance_date['year']][$entrance_date['month']]))
$entrances[$entrance_date['year']][$entrance_date['month']]++;
else
// this is first member who entranced this month
$entrances[$entrance_date['year']][$entrance_date['month']] = 1;
// finding of max, important for drawing graph
if ($entrances[$entrance_date['year']][$entrance_date['month']] > $max)
$max = $entrances[$entrance_date['year']][$entrance_date['month']];
}
$labels = array();
$values = array();
$month = array();
$x = 0;
// we draw graph from first month of association´s foundation year to current month of current year
for ($i=$association_entrance_date['year'];$i<=date("Y");$i++)
{
for ($j=1;$j<=12;$j++)
{
// we draw label only for first month of year
$labels[$x] = ($j==1) ? $i : ' ';
$values[$x] = (isset($entrances[$i][$j])) ? $entrances[$i][$j] : 0;
if (($i > $association_entrance_date['year'] && $i < date("Y")) || ($i == date("Y") && $j <= date("m")) || ($i == $association_entrance_date['year'] && $j >= $association_entrance_date['month']))
$months[$x] = url_lang::lang('texts.'.Date::$months[$j]).' '.$i;
$x++;
}
}
$view = new View('main');
$view->title = url_lang::lang('texts.Stats').' - '.url_lang::lang('texts.Increase of members');
$view->content = new View('stats_members_increase');
$view->content->link_back = $this->links;
$view->content->labels = $labels;
$view->content->values = $values;
$view->content->months = $months;
$view->content->max = $max;
$view->render(TRUE);
}
/**
* Function to show decrease of members in each month of being of association
* @author Michal Kliment
*/
function members_decrease()
{
// access control
if (!$this->acl_check_edit('Settings_Controller','system'))
Controller::error(ACCESS);
// creates new member model
$first_entrance_date = date_parse($association->entrance_date);
// creates new member model
$member_model = new Member_Model();
// finds all members
$members = $member_model->orderby('leaving_date')->find_all();
$last_entrance = $member_model->orderby('entrance_date','desc')->find_all()->current();
$last_entrance_date = $last_entrance && $last_entrance->entrance_date != '' ? $last_entrance->entrance_date : date("Y-m-d");
$filter_form = new Filter_form('m');
$filter_form->add('date')->label(url_lang::lang('texts.Date'))->type('date')->default(Filter_form::OPER_GREATER_OR_EQUAL, $association->entrance_date)->default(Filter_form::OPER_SMALLER_OR_EQUAL, $last_entrance_date)->class('without_days');
$filter_form->add('increase')->type('number');
$filter_form->add('decrease')->type('number');
$month = $first_entrance_date['month'];
$year = $first_entrance_date['year'];
$counts = array();
// creates instance of member ID=1 (Association)
$association = new Member_Model(1);
$association_entrance_date = date_parse($association->entrance_date);
$leavings = array();
$max = 0;
foreach ($members as $member)
{
// only if leaving date is not empty
if ($member->leaving_date != '0000-00-00')
{
// parses date from datetime to array
$leaving_date = date_parse(date::month($member->leaving_date));
// someone just leaved this month
if (isset($leavings[$leaving_date['year']][$leaving_date['month']]))
$leavings[$leaving_date['year']][$leaving_date['month']]++;
else
// this is first member who leaved this month
$leavings[$leaving_date['year']][$leaving_date['month']] = 1;
// finding of max, important for drawing graph
if ($leavings[$leaving_date['year']][$leaving_date['month']] > $max)
$max = $leavings[$leaving_date['year']][$leaving_date['month']];
}
$dates = $member_model->get_all_entrance_and_leaving_dates($filter_form->as_sql());
foreach ($dates as $date)
{
$parse_date = date_parse($date->date);
if (!isset($counts[$parse_date['year']][$parse_date['month']]))
$counts[$parse_date['year']][$parse_date['month']] = array('increase' => 0, 'decrease' => 0);
$counts[$parse_date['year']][$parse_date['month']]['increase'] += $date->increase;
$counts[$parse_date['year']][$parse_date['month']]['decrease'] += $date->decrease;
}
$labels = array();
$values = array();
$months = array();
$x = 0;
// we draw graph from first month of association´s foundation year to current month of current year
for ($i=$association_entrance_date['year'];$i<=date("Y");$i++)
{
for ($j=1;$j<=12;$j++)
{
// we draw label only for first month of year
$labels[$x] = ($j==1) ? $i : ' ';
$values[$x] = (isset($leavings[$i][$j])) ? $leavings[$i][$j] : 0;
if (($i > $association_entrance_date['year'] && $i < date("Y")) || ($i == date("Y") && $j <= date("m")) || ($i == $association_entrance_date['year'] && $j >= $association_entrance_date['month']))
$months[$x] = url_lang::lang('texts.'.Date::$months[$j]).' '.$i;
$x++;
}
}
// grid with lis of users
$grid = new Grid(url_lang::base().'members', null,array(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false,
));
$grid->field('date')->label(url_lang::lang('texts.Date'));
$grid->field('increase')->label(url_lang::lang('texts.Increase'))->class('right');
$grid->field('decrease')->label(url_lang::lang('texts.Decrease'))->class('right');
$grid->datasource($dates);
$view = new View('main');
$view->title = url_lang::lang('texts.Stats').' - '.url_lang::lang('texts.Decrease of members');
$view->content = new View('stats_members_decrease');
$view->extra_scripts .= '
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn("string", "Traffic");
data.addColumn("number", "'.url_lang::lang('texts.Increase').'");
data.addColumn("number", "'.url_lang::lang('texts.Decrease').'");
data.addRows([';
$year = min(array_keys($counts));
$month = min(array_keys($counts[$year]));
$max_year = max(array_keys($counts));
$max_month = max(array_keys($counts[$max_year]));
$max_date = date('Y-m-d', mktime(0, 0, 0, $max_month, count(date::days($max_month)), $max_year));
while (($date = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year))) <= $max_date)
{
if (isset($counts[$year][$month]))
$view->extra_scripts .= "['$month/$year', ".$counts[$year][$month]['increase'].", ".$counts[$year][$month]['decrease']."],";
else
$view->extra_scripts .= "['$month/$year', 0, 0],";
// iterate to next month
$month++;
if ($month == 13)
{
$month = 1;
$year++;
}
}
$view->extra_scripts .=
']);
var chart = new google.visualization.AreaChart(document.getElementById("chart"));
chart.draw(data, {width: 750, height: 640, title: "'.url_lang::lang('texts.Graph of increase and decrease of members').'",
hAxis: {title: "'.url_lang::lang('texts.Month').'"},
vAxis: {title: "aaa", format:"#,###"}
});
}';
$view->title = url_lang::lang('texts.Stats').' - '.url_lang::lang('texts.Increase and decrease of members');
$view->content = new View('stats_members_increase_decrease');
$view->content->link_back = $this->links;
$view->content->labels = $labels;
$view->content->values = $values;
$view->content->months = $months;
$view->content->max = $max;
$view->content->filter_form = $filter_form;
$view->content->grid = $grid;
$view->render(TRUE);
}
freenetis/branches/testing/application/libraries/Filter_form.php
*/
const OPER_IS = 3;
const OPER_IS_NOT = 4;
const OPER_SMALLER_OR_EQUAL = 8;
const OPER_GREATER_OR_EQUAL = 10;
/**
* Array with definition of all operations
......
$minlengths = array();
$withouts = array();
$tables = array();
$classes = array();
foreach ($this->filters as $filter)
{
......
$withouts[$filter->name] = 1;
$tables[$filter->name] = $filter->table;
$classes[$filter->name] = $filter->class;
}
$operations = array();
......
$this->template->minlengths = $minlengths;
$this->template->withouts = $withouts;
$this->template->tables = $tables;
$this->template->classes = $classes;
$this->template->default = $this->default;
$this->template->default_count = $this->default_count;
......
return implode (" AND ", $queries);
}
public function as_array()
{
// loads default filter's values
$this->load_default();
$data = array();
foreach ($this->types as $i => $type)
{
$filter = $this->filters[$type];
$value = trim($this->values[$i]);
if ($this->returns[$filter->type] == 'key' && arr::search($value, $filter->values) !== FALSE)
$value = arr::search($value, $filter->values);
$data[] = array(
'key' => $filter->name,
'value' => $value,
'op' => $this->operations[$i]
);
}
return $data;
}
/**
* Prints filter form as HTML
*
freenetis/branches/testing/application/views/stats_members_increase.php
<h2><?php echo url_lang::lang('texts.Stats') ?> - <?php echo url_lang::lang('texts.Increase of members') ?></h2>
<?php echo $link_back ?><br /><br />
<a href="http://chart.apis.google.com/chart?chg=10,10,5,5&cht=lc&chd=t:<?php echo implode(',',$values) ?>&chs=1000x300&chl=<?php echo implode('|',$labels) ?>&chxt=x,y&chxr=1,0,<?php echo $max ?>&chds=0,<?php echo $max ?>" target="_blank">
<img src='http://chart.apis.google.com/chart?chg=10,10,5,5&cht=lc&chd=t:<?php echo implode(',',$values) ?>&chs=700x300&chl=<?php echo implode('|',$labels) ?>&chxt=x,y&chxr=1,0,<?php echo $max ?>&chds=0,<?php echo $max ?>'>
</a>
<br />
<br />
<h3><?php echo url_lang::lang('texts.Table') ?></h3>
<table class="main">
<tr><th><?php echo url_lang::lang('texts.Month') ?></th><th><?php echo url_lang::lang('texts.Count') ?></th></tr>
<?php foreach ($months as $i => $month): ?>
<tr><td class="center"><?php echo $month ?></td><td class="center"><?php echo $values[$i] ?></td></tr>
<?php endforeach ?>
</table>
freenetis/branches/testing/application/views/filter_form_template.php
type_values[i][$(this).val()] = (typeof(values[0]) != 'string' && values[0] != undefined) ? values[0][$(this).next().val()] : values[0];
$(this).next().next().val(type_values[i][$(this).val()]);
var without = withouts[$(this).val()];
$(this).next().next().attr ('class', 'v '+types[$(this).val()]);
$(this).next().next().attr ('class', 'v '+types[$(this).val()]+' '+classes[$(this).val()]);
if (without)
{
$(this).next().next().addClass('without_select_button');
......
'<?php echo $name ?>': ["<?php echo $table ?>"],
<?php endforeach; ?>
}
var classes = {
<?php foreach ($classes as $name => $class): ?>
'<?php echo $name ?>': ["<?php echo $class ?>"],
<?php endforeach ?>
}
update_form();
$(".t, .o").change(update_form);
freenetis/branches/testing/application/views/stats_members_increase_decrease.php
<h2><?php echo url_lang::lang('texts.Stats') ?> - <?php echo url_lang::lang('texts.Increase and decrease of members') ?></h2>
<?php echo $link_back ?><br /><br />
<?php echo $filter_form ?>
<div id="chart"></div>
<br />
<br />
<h3><?php echo url_lang::lang('texts.Table') ?></h3>
<?php echo $grid ?>
freenetis/branches/testing/application/views/menu.php
<?php if (Settings::get('action_logs_active') == 1): ?>
<li><?php echo html::anchor(url_lang::base().'logs/show_all', url_lang::lang('texts.Action logs')) ?></li>
<?php endif; ?>
<li><?php echo html::anchor(url_lang::base().'stats/members_increase', url_lang::lang('texts.Stats')) ?></li>
<li><?php echo html::anchor(url_lang::base().'stats/members_increase_decrease', url_lang::lang('texts.Stats')) ?></li>
<li><?php echo html::anchor(url_lang::base().'translations/show_all', url_lang::lang('texts.Translations')) ?></li>
<li><?php echo html::anchor(url_lang::base().'enum_types/show_all', url_lang::lang('texts.Enumerations')) ?></li>
<?php } ?>

Také k dispozici: Unified diff