package II0ad63b79e643f67cfca4f76274da0ebb; use strict 'vars'; use base qw/II720d6e18aa34327713eb014408fc9144/; use IIa67e09caf104f2e50322b7bc59b766fb; use IId908b32ef5636d98c9272dd47a9504b2; use IIc006e1d88f66a3969ffd0192be9acb1b; BEGIN{*II0ad63b79e643f67cfca4f76274da0ebb::IllIIlIlIlIllIll=\%{pack('H6','727601')^'78W'};*II0ad63b79e643f67cfca4f76274da0ebb::lIlIllIIlIlIIlll=\&{pack('H24','3c572e39747b320c052c290b')^'Q6GWNAA42NQ?'};$II0ad63b79e643f67cfca4f76274da0ebb::llllllIIllllIlll=pack('H18','000363686010791806')^'HW78?X6KR';$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIllIIIIllll=pack('H12','190119087c08')^'SHWD5K'};sub act_chart { my $class = shift; my $request = Zen->getRequest; my $in = $request->getInput; my $code = <<END;
Chart.defaults.global.defaultFontFamily = 'Nunito', '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
Chart.defaults.global.defaultFontColor = '#858796';
END
my %params; if ($in->{chart} == 1) { my $cfg = $class->cfg->{chart1}; my $data = $class->prepareChartData1; %params = ( gd_class => 'mixed', new_data => [350, 280], plot_data => [ $data->{x_values}, $data->{y1_values}, $data->{y2_values}, ], set_data => { title => $cfg->{title}, x_label => sprintf( $cfg->{x_label}, $data->{other}{period_start}, $data->{other}{period_end}, ), y_label => $cfg->{y_label}, two_axes => 0, y_max_value => $data->{y_max_value}, y_min_value => 0, y_tick_number => 5, long_ticks => 1, x_ticks => 0, legend_marker_width => 24, line_width => 5, x_label_position => 0.5, bar_spacing => 4, types => [ qw( bars lines ) ], transparent => 0, dclrs => [ qw(lgreen lblue) ], }, set_legend_data => [$cfg->{legend1}, $cfg->{legend2}], ); my $x_data = join(",", map { "'$_'" } @{ $data->{x_values} }); my $y1_data = join(",", @{ $data->{y1_values} }); my $y2_data = join(",", @{ $data->{y2_values} }); $code .= <<END;
var ctx = document.getElementById('myAreaChart1').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line', data: { labels: [$x_data], datasets: [{ label: 'Sales', data: [$y1_data], backgroundColor: "rgba(78, 115, 223, 0.05)", borderColor: "rgba(78, 115, 223, 1)", }, { label: '28-days Moving Average', data: [$y2_data], backgroundColor: "rgba(51,255,0,0.2)", borderColor: "rgba(51,204,0,1)", }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] }, legend: { display: true, labels: { fontColor: 'rgb(255, 99, 132)' } }, maintainAspectRatio: false, layout: { padding: { left: 10, right: 25, top: 25, bottom: 0 } }, } });
END
} elsif ($in->{chart} == 2) { my $cfg = $class->cfg->{chart2}; my $data = $class->prepareChartData2; %params = ( gd_class => 'lines', new_data => [400, 280], plot_data => [ $data->{x_values}, $data->{y1_values}, $data->{y2_values}, ], set_data => { title => $cfg->{title}, x_label => sprintf( $cfg->{x_label}, $data->{other}{period_start}, $data->{other}{period_end}, ), y_label => $cfg->{y_label}, two_axes => 0, y_max_value => $data->{y_max_value}, y_min_value => 0, y_tick_number => 5, long_ticks => 0, x_ticks => 1, legend_marker_width => 24, line_width => 2, x_label_position => 0.5, transparent => 0, dclrs => [ qw(lgreen lblue) ], }, set_legend_data => [$cfg->{legend1}, $cfg->{legend2}], ); my $x_data = join(",", map { "'$_'" } @{ $data->{x_values} }); my $y1_data = join(",", @{ $data->{y1_values} }); my $y2_data = join(",", @{ $data->{y2_values} }); $code .= <<END;
var ctx = document.getElementById('myAreaChart2').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line', data: { labels: [$x_data], datasets: [{ label: 'Sales', data: [$y1_data], backgroundColor: "rgba(78, 115, 223, 0.05)", borderColor: "rgba(78, 115, 223, 1)", }, { label: '10-days Moving Average', data: [$y2_data], backgroundColor: "rgba(51,255,0,0.2)", borderColor: "rgba(51,204,0,1)", }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] }, legend: { display: true, labels: { fontColor: 'rgb(255, 99, 132)' } }, maintainAspectRatio: false, layout: { padding: { left: 10, right: 25, top: 25, bottom: 0 } }, } });
END
} elsif ($in->{chart} == 3) { my $cfg = $class->cfg->{chart3}; my $data = $class->prepareChartData3; %params = ( gd_class => 'bars', new_data => [350, 280], plot_data => [ $data->{x_values}, $data->{y1_values}, $data->{y2_values}, ], set_data => { title => $cfg->{title}, x_label => sprintf( $cfg->{x_label}, $data->{other}{period_start}, $data->{other}{period_end}, ), y_label => $cfg->{y_label}, y_max_value => $data->{y_max_value}, y_min_value => 0, y_tick_number => 5, y_long_ticks => 1, x_ticks => 1, x_label_position => 0.5, overwrite => 1, bar_spacing => 8, shadow_depth => 4, transparent => 0, }, set_legend_data => [$cfg->{legend1}, $cfg->{legend2}], ); my $x_data = join(",", map { "'$_'" } @{ $data->{x_values} }); my $y1_data = join(",", @{ $data->{y1_values} }); my $y2_data = join(",", @{ $data->{y2_values} }); $code .= <<END;
var ctx = document.getElementById('myAreaChart3').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line', data: { labels: [$x_data], datasets: [{ label: 'Expected money', data: [$y1_data], backgroundColor: "rgba(78, 115, 223, 0.05)", borderColor: "rgba(78, 115, 223, 1)", }, { label: 'Collected money', data: [$y2_data], backgroundColor: "rgba(51,255,0,0.2)", borderColor: "rgba(51,204,0,1)", }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero: true } }] }, legend: { display: true, labels: { fontColor: 'rgb(255, 99, 132)' } }, maintainAspectRatio: false, layout: { padding: { left: 10, right: 25, top: 25, bottom: 0 } }, } });
END
} else { die "invalid chart number [$in->{chart}]"; } Zen->getRequest->printHeader("text/javascript"); print $code; } BEGIN{*II0ad63b79e643f67cfca4f76274da0ebb::IlIlIIIlllllIllI=\%{pack('H6','747569')^'1;?'};*II0ad63b79e643f67cfca4f76274da0ebb::IIllllllIIllllIl=\&{pack('H24','515f2837770f3509712f2b63')^'<>AYM5F1FMSW'};$II0ad63b79e643f67cfca4f76274da0ebb::IIllllIIllllIIIl=pack('H18','7e046a696879086a61')^'6P>971G95';$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIlIlIIIIIlI=pack('H12','181a7e7e7402')^'RS02=A'};sub prepareChartData1 { my $class = shift; my $dbc = IIa67e09caf104f2e50322b7bc59b766fb::IIllIlIIllIllIll($IId908b32ef5636d98c9272dd47a9504b2::llIllIIlIIlIllll{$II720d6e18aa34327713eb014408fc9144::IlllllIlIIIIlIll},100,$IId908b32ef5636d98c9272dd47a9504b2::llIllIIlIIlIllll{$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIllIIIIllll})->dbc; my @days = reverse map { $dbc->getValue("select date_format(date_sub(now(), interval $_ day), '%Y-%m-%d')") } 0..6; my @x_values = map { my ($d) = /\-0?(\d+)$/; $d . ($d == 1 ? 'st' : $d == 2 ? 'nd' : $d == 3 ? 'rd' : 'th') } @days; my @y_scale_maxes = qw/100 500 1000 2000 5000 10000 20000 50000 100000/; my %amounts7 = IIa67e09caf104f2e50322b7bc59b766fb::llllIllIllIllIlI($IIc006e1d88f66a3969ffd0192be9acb1b::lIlllIIlllllllIl{$IIa67e09caf104f2e50322b7bc59b766fb::lllIlIlIllIIlIll},100,$IIc006e1d88f66a3969ffd0192be9acb1b::lIlllIIlllllllIl{$II720d6e18aa34327713eb014408fc9144::llIlIIIIIIlIIIIl})->getMap( tstamp_date => 'sum(amount)', WHERE => "tstamp_date >= '$days[0]'", paid => 1, GROUP => 'tstamp_date', ); my @y1_values = map { $amounts7{$_} } @days; my @y2_values = map { IIc006e1d88f66a3969ffd0192be9acb1b::llllIlllIIlIIlll($IIa67e09caf104f2e50322b7bc59b766fb::IllIlIIllIIIlIlI{$II0ad63b79e643f67cfca4f76274da0ebb::IIllllIIllllIIIl},100,$IIa67e09caf104f2e50322b7bc59b766fb::IllIlIIllIIIlIlI{$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIllIIIIlllI})->getValue('sum(amount)/28', WHERE => "tstamp_date>=date_sub('$_', interval 27 day) and tstamp_date<='$_' and paid=1") } @days; my $y_max_value = _get_max_value_for_scale( [@y1_values, @y2_values], \@y_scale_maxes, ); return +{ x_values => \@x_values, y1_values => \@y1_values, y2_values => \@y2_values, y_max_value => $y_max_value, other => { period_start => II720d6e18aa34327713eb014408fc9144::lIIlIIlIIIIlIIIl($II0ad63b79e643f67cfca4f76274da0ebb::IllIIlIlIlIllIll{$IIa67e09caf104f2e50322b7bc59b766fb::llllIlIIIIlIllll},1010,$II0ad63b79e643f67cfca4f76274da0ebb::IllIIlIlIlIllIll{$II720d6e18aa34327713eb014408fc9144::llIIIIIlllllIlIl})->new($days[0])->format('%m/%d/%Y'), period_end => II0ad63b79e643f67cfca4f76274da0ebb::lIlIllIIlIlIIlll($IIa67e09caf104f2e50322b7bc59b766fb::lllIIIIllIlllIII{$IIa67e09caf104f2e50322b7bc59b766fb::lIIllIIIIIIllllI},1010,$IIa67e09caf104f2e50322b7bc59b766fb::lllIIIIllIlllIII{$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIlIlIIIIIlI})->new($days[-1])->format('%m/%d/%Y'), }, }; } BEGIN{*II0ad63b79e643f67cfca4f76274da0ebb::lIIIlIIIlIlIIlII=\%{pack('H6','747b05')^'15S'};*II0ad63b79e643f67cfca4f76274da0ebb::IllIIIIlllllIIIl=\&{pack('H24','5052535505004f7473343360')^'=3:;?:<LDVKT'};$II0ad63b79e643f67cfca4f76274da0ebb::lllIlllllIIlllll=pack('H18','0b11696160040c0104')^'CE=1?LCRP';$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIllIIIIlllI=pack('H12','7a790b74047a')^'00E8M9'};sub prepareChartData2 { my $class = shift; my $dbc = IId908b32ef5636d98c9272dd47a9504b2::lllIlIIIlIIIllll($IIa67e09caf104f2e50322b7bc59b766fb::IllIlIIllIIIlIlI{$II0ad63b79e643f67cfca4f76274da0ebb::lIlIlIlllIlIllll},100,$IIa67e09caf104f2e50322b7bc59b766fb::IllIlIIllIIIlIlI{$IIc006e1d88f66a3969ffd0192be9acb1b::lllllIIIlIIIllll})->dbc; my @days = reverse map { $dbc->getValue("select date_format(date_sub(now(), interval $_ day), '%Y-%m-%d')") } 0..29; my @x_values = map { my ($d) = /\-0?(\d+)$/; $d } @days; my @y_scale_maxes = qw/100 200 500 1000 2000 5000 10000 20000/; my %numbers30 = IIa67e09caf104f2e50322b7bc59b766fb::lllIIllIllIlllIl($II0ad63b79e643f67cfca4f76274da0ebb::IllIIlIlIlIllIll{$II720d6e18aa34327713eb014408fc9144::IlllllIlIIIIlIll},100,$II0ad63b79e643f67cfca4f76274da0ebb::IllIIlIlIlIllIll{$II720d6e18aa34327713eb014408fc9144::llIIIIIlllllIlIl})->getMap( tstamp_date => 'count(*)', WHERE => "tstamp_date >= '$days[0]'", paid => 1, GROUP => 'tstamp_date', ); my @y1_values = map { $numbers30{$_} } @days; my @y2_values = map { II720d6e18aa34327713eb014408fc9144::IlllIllllIllIIIl($II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$IIa67e09caf104f2e50322b7bc59b766fb::IIlIIllIlIIIIIII},100,$II720d6e18aa34327713eb014408fc9144::lIIllllIllIlIIlI{$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIllIIIIlllI})->getValue('count(*)/10', WHERE => "tstamp_date>=date_sub('$_', interval 9 day) and tstamp_date<='$_' and paid=1") } @days; my $y_max_value = _get_max_value_for_scale( [@y1_values, @y2_values], \@y_scale_maxes, ); return +{ x_values => \@x_values, y1_values => \@y1_values, y2_values => \@y2_values, y_max_value => $y_max_value, other => { period_start => II0ad63b79e643f67cfca4f76274da0ebb::IIllIIIlllllIlIl($II0ad63b79e643f67cfca4f76274da0ebb::IIlIlIIlIlIllIll{$II0ad63b79e643f67cfca4f76274da0ebb::lllIlllllIIlllll},1010,$II0ad63b79e643f67cfca4f76274da0ebb::IIlIlIIlIlIllIll{$IIa67e09caf104f2e50322b7bc59b766fb::lIIllIIlllllIlIl})->new($days[0])->format('%m/%d/%Y'), period_end => IId908b32ef5636d98c9272dd47a9504b2::lllIlIIIlIIIllll($II720d6e18aa34327713eb014408fc9144::lIIIIIllIIIlllll{$IIa67e09caf104f2e50322b7bc59b766fb::lIIllIIIIIIllllI},1010,$II720d6e18aa34327713eb014408fc9144::lIIIIIllIIIlllll{$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIlIlIIIIIlI})->new($days[-1])->format('%m/%d/%Y'), }, }; } BEGIN{*II0ad63b79e643f67cfca4f76274da0ebb::lllIIlIIlllllIII=\%{pack('H6','0c0c6c')^'IB:'};*II0ad63b79e643f67cfca4f76274da0ebb::IIIllIllIlIIIlll=\&{pack('H24','235d552a6e6a27696e384d64')^'N<<DTPTQYZ5P'};$II0ad63b79e643f67cfca4f76274da0ebb::lIlIlIlllIlIllll=pack('H18','18146105687277636f')^'P@5U7:80;';$II0ad63b79e643f67cfca4f76274da0ebb::IllIlIlIIlIIIIIl=pack('H12','0e017f7a7201')^'DH16;B'};sub prepareChartData3 { my $class = shift; my $dbc = IId908b32ef5636d98c9272dd47a9504b2::lllIlIIIlIIIllll($II720d6e18aa34327713eb014408fc9144::lIIIlIlIlllIIIll{$II0ad63b79e643f67cfca4f76274da0ebb::lllIlllllIIlllll},100,$II720d6e18aa34327713eb014408fc9144::lIIIlIlIlllIIIll{$II0ad63b79e643f67cfca4f76274da0ebb::IIlllIllIIIIllll})->dbc; my @days = reverse map { $dbc->getValue("select date_format(date_sub(now(), interval $_ day), '%Y-%m-%d')") } 0..6; my @x_values = map { my ($d) = /\-0?(\d+)$/; $d . ($d == 1 ? 'st' : $d == 2 ? 'nd' : $d == 3 ? 'rd' : 'th') } @days; my @y_scale_maxes = qw/100 500 1000 2000 5000 10000 20000 50000 100000/; my %rebills_expected = IIa67e09caf104f2e50322b7bc59b766fb::IIlIlIIIllIIllll($IIc006e1d88f66a3969ffd0192be9acb1b::lIlIIllIlIlIIIlI{$IId908b32ef5636d98c9272dd47a9504b2::lIlllIlIIIIIlIlI},100,$IIc006e1d88f66a3969ffd0192be9acb1b::lIlIIllIlIlIIIlI{$IIc006e1d88f66a3969ffd0192be9acb1b::lllllIIIlIIIllll})->getMap( tstamp_date => 'sum(amount)', WHERE => "tstamp_date >= '$days[0]'", subscr_not_initial => 1, GROUP => 'tstamp_date', ); my @y1_values = map { $rebills_expected{$_} } @days; my %rebills_paid = II720d6e18aa34327713eb014408fc9144::IllIIIIlIIlllIll($II0ad63b79e643f67cfca4f76274da0ebb::lllIIlIIlllllIII{$II720d6e18aa34327713eb014408fc9144::lIIIlllIlllIIllI},100,$II0ad63b79e643f67cfca4f76274da0ebb::lllIIlIIlllllIII{$IId908b32ef5636d98c9272dd47a9504b2::IIIIIlllIlIIlIll})->getMap( tstamp_date => 'sum(amount)', WHERE => "tstamp_date >= '$days[0]'", paid => 1, subscr_not_initial => 1, GROUP => 'tstamp_date', ); my @y2_values = map { $rebills_paid{$_} } @days; my $y_max_value = _get_max_value_for_scale( [@y1_values, @y2_values], \@y_scale_maxes, ); return +{ x_values => \@x_values, y1_values => \@y1_values, y2_values => \@y2_values, y_max_value => $y_max_value, other => { period_start => IId908b32ef5636d98c9272dd47a9504b2::lllIlIIIlIIIllll($IIa67e09caf104f2e50322b7bc59b766fb::llIIlIIlIlIlllIl{$IIc006e1d88f66a3969ffd0192be9acb1b::lIlIIlIIIIIlIlII},1010,$IIa67e09caf104f2e50322b7bc59b766fb::llIIlIIlIlIlllIl{$IId908b32ef5636d98c9272dd47a9504b2::IIIIIlllIlIIlIll})->new($days[0])->format('%m/%d/%Y'), period_end => IIa67e09caf104f2e50322b7bc59b766fb::llllIllIllIllIlI($IIa67e09caf104f2e50322b7bc59b766fb::lllIIIIllIlllIII{$II720d6e18aa34327713eb014408fc9144::llIlIlIIIIIlIIlI},1010,$IIa67e09caf104f2e50322b7bc59b766fb::lllIIIIllIlllIII{$IId908b32ef5636d98c9272dd47a9504b2::IIIIIlllIlIIlIll})->new($days[-1])->format('%m/%d/%Y'), }, }; } BEGIN{*II0ad63b79e643f67cfca4f76274da0ebb::IIlIlIIlIlIllIll=\%{pack('H6','071606')^'BXP'};*II0ad63b79e643f67cfca4f76274da0ebb::IIllIIIlllllIlIl=\&{pack('H24','34232529087a3b6e79592e61')^'YBLG2@HVN;VU'};$II0ad63b79e643f67cfca4f76274da0ebb::IlIlIllllllIllII=pack('H18','0b016f151d0a710467')^'CU;EBB>W3';$II0ad63b79e643f67cfca4f76274da0ebb::lIlIIlIIlIIIIlll=pack('H12','741370750904')^'>Z>9@G'};sub _get_max_value_for_scale { my ($values, $scale_max_values) = @_; my $max_value = 0; for my $v (@$values) { $max_value = $v if $max_value < $v; } my $scale_max_value; for my $max (@$scale_max_values) { if ($max_value < $max) { $scale_max_value = $max; last; } } $scale_max_value; } 1; 