/** * Direcly renders chart by current month payments * * @return string */ public function renderChart() { $result = ''; $allPayments = $this->getMonthPayments(); $chartData = array(); $tmpArr = array(); if (!empty($allPayments)) { $chartData[] = array(__('Day'), __('Cash')); foreach ($allPayments as $io => $each) { $paymentDate = strtotime($each['date']); $paymentDate = date("d", $paymentDate); if (isset($tmpArr[$paymentDate])) { $tmpArr[$paymentDate] += $each['summ']; } else { $tmpArr[$paymentDate] = $each['summ']; } } if (!empty($tmpArr)) { foreach ($tmpArr as $day => $cash) { $chartData[] = array($day, $cash); } } $result = $this->widgetContainer(wf_gchartsLine($chartData, __('Month payments'), '500px', '256px', '')); } return $result; }
/** * Renders per-payment system openpayz transaction charts * * @return string */ public function renderGraphs() { $psysdata = array(); $gcAllData = array(); $gcMonthData = array(); $gchartsData = array(); $chartsOptions = "\n 'focusTarget': 'category',\n 'hAxis': {\n 'color': 'none',\n 'baselineColor': 'none',\n },\n 'vAxis': {\n 'color': 'none',\n 'baselineColor': 'none',\n },\n 'curveType': 'function',\n 'pointSize': 5,\n 'crosshair': {\n trigger: 'none'\n },"; $result = wf_Link('?module=openpayz', __('Back'), true, 'ubButton'); if (!empty($this->allTransactions)) { foreach ($this->allTransactions as $io => $each) { $timestamp = strtotime($each['date']); $curMonth = curmonth(); $date = date("Y-m", $timestamp); if (isset($psysdata[$each['paysys']][$date]['count'])) { $psysdata[$each['paysys']][$date]['count']++; $psysdata[$each['paysys']][$date]['summ'] = $psysdata[$each['paysys']][$date]['summ'] + $each['summ']; } else { $psysdata[$each['paysys']][$date]['count'] = 1; $psysdata[$each['paysys']][$date]['summ'] = $each['summ']; } //all time stats if (isset($gcAllData[$each['paysys']])) { $gcAllData[$each['paysys']]++; } else { $gcAllData[$each['paysys']] = 1; } //current month stats if (ispos($date, $curMonth)) { if (isset($gcMonthData[$each['paysys']])) { $gcMonthData[$each['paysys']]++; } else { $gcMonthData[$each['paysys']] = 1; } } } } $chartOpts = "chartArea: { width: '90%', height: '90%' }, legend : {position: 'right'}, "; if (!empty($gcAllData)) { $gcAllPie = wf_gcharts3DPie($gcAllData, __('All time'), '400px', '400px', $chartOpts); } else { $gcAllPie = ''; } if (!empty($gcMonthData)) { $gcMonthPie = wf_gcharts3DPie($gcMonthData, __('Current month'), '400px', '400px', $chartOpts); } else { $gcMonthPie = ''; } $gcells = wf_TableCell($gcAllPie); $gcells .= wf_TableCell($gcMonthPie); $grows = wf_TableRow($gcells); $result .= wf_TableBody($grows, '100%', 0, ''); if (!empty($psysdata)) { foreach ($psysdata as $psys => $opdate) { $gchartsData[] = array(__('Date'), __('Count'), __('Cash')); foreach ($opdate as $datestamp => $optrans) { $gchartsData[] = array($datestamp, $optrans['count'], $optrans['summ']); } $result .= wf_gchartsLine($gchartsData, $psys, '100%', '300px;', $chartsOptions); $gchartsData = array(); } } return $result; }
/** * Returns graph of planned tasks in taskmanager * * @param int $year * @return string */ function web_AnalyticsTaskmanMonthGraph($year) { $allmonths = months_array(); $yearcount = zb_AnalyticsTaskmanGetCountYear($year); $chartData = array(0 => array(__('Month'), __('Jobs'))); $chartOptions = "\n 'focusTarget': 'category',\n 'hAxis': {\n 'color': 'none',\n 'baselineColor': 'none',\n },\n 'vAxis': {\n 'color': 'none',\n 'baselineColor': 'none',\n },\n 'curveType': 'function',\n 'pointSize': 5,\n 'crosshair': {\n trigger: 'none'\n },"; foreach ($yearcount as $eachmonth => $count) { $chartData[] = array($year . '-' . $eachmonth, $count); } $result = wf_gchartsLine($chartData, __('Task manager activity during the year'), '100%', '400px', $chartOptions) . wf_delimiter(); return $result; }
/** * Renders report for some year * * @return string */ public function renderReport() { $result = ''; $months = months_array_localized(); $yearData = $this->loadStoredData(); $inputs = wf_YearSelectorPreset('yearsel', __('Year'), false, $this->showYear) . ' '; $chartsFlag = wf_CheckPost(array('showcharts')) ? true : false; $inputs .= wf_CheckInput('showcharts', __('Graphs'), false, $chartsFlag) . ' '; $inputs .= wf_Submit(__('Show')); $yearForm = wf_Form('', 'POST', $inputs, 'glamour'); $yearForm .= wf_CleanDiv(); $result .= $yearForm; //charts presets $chartsOptions = "\n 'focusTarget': 'category',\n 'hAxis': {\n 'color': 'none',\n 'baselineColor': 'none',\n },\n 'vAxis': {\n 'color': 'none',\n 'baselineColor': 'none',\n },\n 'curveType': 'function',\n 'pointSize': 5,\n 'crosshair': {\n trigger: 'none'\n },"; $usersChartData = array(0 => array(__('Month'), __('Total'), __('Active'), __('Inactive'), __('Frozen'), __('Signups'))); $complexChartData = array(0 => array(__('Month'), __('Total'), __('Active'), __('Inactive'))); $financeChartsData = array(0 => array(__('Month'), __('Money'), __('Payments count'), __('ARPU'), __('ARPAU'))); $ukvChartData = array(0 => array(__('Month'), __('Total'), __('Active'), __('Inactive'), __('Illegal'), __('Complex'), __('Social'), __('Signups'))); $ukvfChartData = array(0 => array(__('Month'), __('Money'), __('Payments count'), __('ARPU'), __('ARPAU'), __('Debt'))); $askoziaChartData = array(0 => array(__('Month'), __('Total calls'), __('Total answered'), __('No answer'))); $equipChartData = array(0 => array(__('Month'), __('Switches'), __('PON ONU'), __('DOCSIS modems'))); if (!empty($yearData)) { //internet users $cells = wf_TableCell(__('Month')); $cells .= wf_TableCell(__('Total')); $cells .= wf_TableCell(__('Active')); $cells .= wf_TableCell(__('Inactive')); $cells .= wf_TableCell(__('Frozen')); $cells .= wf_TableCell(__('Signups')); $rows = wf_TableRow($cells, 'row1'); foreach ($yearData as $monthNum => $each) { $cells = wf_TableCell($months[$monthNum]); $cells .= wf_TableCell($each['u_totalusers']); $cells .= wf_TableCell($each['u_activeusers'] . ' (' . $this->percentValue($each['u_totalusers'], $each['u_activeusers']) . '%)'); $cells .= wf_TableCell($each['u_inactiveusers'] . ' (' . $this->percentValue($each['u_totalusers'], $each['u_inactiveusers']) . '%)'); $cells .= wf_TableCell($each['u_frozenusers'] . ' (' . $this->percentValue($each['u_totalusers'], $each['u_frozenusers']) . '%)'); if (!empty($each['u_citysignups'])) { $signupData = ''; $sigDataTmp = base64_decode($each['u_citysignups']); $sigDataTmp = unserialize($sigDataTmp); $citySigs = ''; $cityRows = ''; if (!empty($sigDataTmp)) { $cityCells = wf_TableCell(__('City')); $cityCells .= wf_TableCell(__('Signups')); $cityRows .= wf_TableRow($cityCells, 'row1'); foreach ($sigDataTmp as $sigCity => $cityCount) { $cityCells = wf_TableCell($sigCity); $cityCells .= wf_TableCell($cityCount); $cityRows .= wf_TableRow($cityCells, 'row3'); } $citySigs .= wf_TableBody($cityRows, '100%', 0, ''); } $signupData .= wf_modalAuto($each['u_signups'], __('Cities'), $citySigs); } else { $signupData = $each['u_signups']; } $cells .= wf_TableCell($signupData); $rows .= wf_TableRow($cells, 'row3'); //chart data $usersChartData[] = array($months[$monthNum], $each['u_totalusers'], $each['u_activeusers'], $each['u_inactiveusers'], $each['u_frozenusers'], $each['u_signups']); } $result .= wf_tag('h2') . __('Internets users') . wf_tag('h2', true); $result .= wf_TableBody($rows, '100%', 0, ''); if ($chartsFlag) { $result .= wf_gchartsLine($usersChartData, __('Internets users'), '100%', '300px', $chartsOptions); } //complex data if ($this->complexFlag) { $result .= wf_tag('h2') . __('Complex services') . wf_tag('h2', true); $cells = wf_TableCell(__('Month')); $cells .= wf_TableCell(__('Total')); $cells .= wf_TableCell(__('Active')); $cells .= wf_TableCell(__('Inactive')); $rows = wf_TableRow($cells, 'row1'); foreach ($yearData as $monthNum => $each) { $cells = wf_TableCell($months[$monthNum]); $cells .= wf_TableCell($each['u_complextotal']); $cells .= wf_TableCell($each['u_complexactive'] . ' (' . $this->percentValue($each['u_complextotal'], $each['u_complexactive']) . '%)'); $cells .= wf_TableCell($each['u_complexinactive'] . ' (' . $this->percentValue($each['u_complextotal'], $each['u_complexinactive']) . '%)'); $rows .= wf_TableRow($cells, 'row3'); //chart data $complexChartData[] = array($months[$monthNum], $each['u_complextotal'], $each['u_complexactive'], $each['u_complexinactive']); } $result .= wf_TableBody($rows, '100%', 0, ''); if ($chartsFlag) { $result .= wf_gchartsLine($complexChartData, __('Complex services'), '100%', '300px', $chartsOptions); } } //finance data $result .= wf_tag('h2') . __('Financial highlights') . wf_tag('h2', true); $cells = wf_TableCell(__('Month')); $cells .= wf_TableCell(__('Money')); $cells .= wf_TableCell(__('Payments count')); $cells .= wf_TableCell(__('Cash payments')); $cells .= wf_TableCell(__('Cash payments count')); $cells .= wf_TableCell(__('ARPU')); $cells .= wf_TableCell(__('ARPAU')); $rows = wf_TableRow($cells, 'row1'); foreach ($yearData as $monthNum => $each) { $cells = wf_TableCell($months[$monthNum]); $cells .= wf_TableCell($each['f_totalmoney']); $cells .= wf_TableCell($each['f_paymentscount']); $cells .= wf_TableCell($each['f_cashmoney'] . ' (' . $this->percentValue($each['f_totalmoney'], $each['f_cashmoney']) . '%)'); $cells .= wf_TableCell($each['f_cashcount'] . ' (' . $this->percentValue($each['f_paymentscount'], $each['f_cashcount']) . '%)'); $cells .= wf_TableCell($each['f_arpu']); $cells .= wf_TableCell($each['f_arpau']); $rows .= wf_TableRow($cells, 'row3'); //chart data $financeChartsData[] = array($months[$monthNum], $each['f_totalmoney'], $each['f_paymentscount'], $each['f_arpu'], $each['f_arpau']); } $result .= wf_TableBody($rows, '100%', 0, ''); if ($chartsFlag) { $result .= wf_gchartsLine($financeChartsData, __('Financial highlights'), '100%', '300px', $chartsOptions); } // UKV cable users if ($this->ukvFlag) { $result .= wf_tag('h2') . __('UKV users') . wf_tag('h2', true); $cells = wf_TableCell(__('Month')); $cells .= wf_TableCell(__('Total')); $cells .= wf_TableCell(__('Active')); $cells .= wf_TableCell(__('Inactive')); $cells .= wf_TableCell(__('Illegal')); if ($this->complexFlag) { $cells .= wf_TableCell(__('Complex')); } $cells .= wf_TableCell(__('Social')); $cells .= wf_TableCell(__('Signups')); $rows = wf_TableRow($cells, 'row1'); foreach ($yearData as $monthNum => $each) { $cells = wf_TableCell($months[$monthNum]); $cells .= wf_TableCell($each['c_totalusers']); $cells .= wf_TableCell($each['c_activeusers'] . ' (' . $this->percentValue($each['c_totalusers'], $each['c_activeusers']) . '%)'); $cells .= wf_TableCell($each['c_inactiveusers'] . ' (' . $this->percentValue($each['c_totalusers'], $each['c_inactiveusers']) . '%)'); $cells .= wf_TableCell($each['c_illegal'] . ' (' . $this->percentValue($each['c_totalusers'], $each['c_illegal']) . '%)'); if ($this->complexFlag) { $cells .= wf_TableCell($each['c_complex'] . ' (' . $this->percentValue($each['c_totalusers'], $each['c_complex']) . '%)'); } $cells .= wf_TableCell($each['c_social'] . ' (' . $this->percentValue($each['c_totalusers'], $each['c_social']) . '%)'); $cells .= wf_TableCell($each['c_signups']); $rows .= wf_TableRow($cells, 'row3'); //chart data $ukvChartData[] = array($months[$monthNum], $each['c_totalusers'], $each['c_activeusers'], $each['c_inactiveusers'], $each['c_illegal'], $each['c_complex'], $each['c_social'], $each['c_signups']); } $result .= wf_TableBody($rows, '100%', 0, ''); if ($chartsFlag) { $result .= wf_gchartsLine($ukvChartData, __('UKV users'), '100%', '300px', $chartsOptions); } //UKV financial data $result .= wf_tag('h2') . __('UKV finance') . wf_tag('h2', true); $cells = wf_TableCell(__('Month')); $cells .= wf_TableCell(__('Money')); $cells .= wf_TableCell(__('Payments count')); $cells .= wf_TableCell(__('ARPU')); $cells .= wf_TableCell(__('ARPAU')); $cells .= wf_TableCell(__('Debt')); $rows = wf_TableRow($cells, 'row1'); foreach ($yearData as $monthNum => $each) { $cells = wf_TableCell($months[$monthNum]); $cells .= wf_TableCell($each['c_totalmoney']); $cells .= wf_TableCell($each['c_paymentscount']); $cells .= wf_TableCell($each['c_arpu']); $cells .= wf_TableCell($each['c_arpau']); $cells .= wf_TableCell($each['c_totaldebt']); $rows .= wf_TableRow($cells, 'row3'); //chart data $ukvfChartData[] = array($months[$monthNum], $each['c_totalmoney'], $each['c_paymentscount'], $each['c_arpu'], $each['c_arpau'], $each['c_totaldebt']); } $result .= wf_TableBody($rows, '100%', 0, ''); if ($chartsFlag) { $result .= wf_gchartsLine($ukvfChartData, __('UKV users'), '100%', '300px', $chartsOptions); } } //Askozia PBX if ($this->askoziaFlag) { $result .= wf_tag('h2') . __('AskoziaPBX integration') . wf_tag('h2', true); $cells = wf_TableCell(__('Month')); $cells .= wf_TableCell(__('Incoming calls')); $cells .= wf_TableCell(__('Total answered')); $cells .= wf_TableCell(__('No answer')); $cells .= wf_TableCell(__('Total duration')); $cells .= wf_TableCell(__('Average duration')); $cells .= wf_TableCell(__('Answers percent')); $rows = wf_TableRow($cells, 'row1'); foreach ($yearData as $monthNum => $each) { $cells = wf_TableCell($months[$monthNum]); $cells .= wf_TableCell($each['a_totalcalls']); $cells .= wf_TableCell($each['a_totalanswered']); $cells .= wf_TableCell($each['a_totalcalls'] - $each['a_totalanswered']); $cells .= wf_TableCell($this->formatTime($each['a_totalcallsduration'])); $cells .= wf_TableCell($this->formatTime($each['a_averagecallduration'])); $cells .= wf_TableCell($this->percentValue($each['a_totalcalls'], $each['a_totalanswered']) . '%'); $rows .= wf_TableRow($cells, 'row3'); //chart data $askoziaChartData[] = array($months[$monthNum], $each['a_totalcalls'], $each['a_totalanswered'], $each['a_totalcalls'] - $each['a_totalanswered']); } $result .= wf_TableBody($rows, '100%', 0, ''); if ($chartsFlag) { $result .= wf_gchartsLine($askoziaChartData, __('Askozia'), '100%', '300px', $chartsOptions); } } //Equipment $result .= wf_tag('h2') . __('Equipment') . wf_tag('h2', true); $cells = wf_TableCell(__('Month')); $cells .= wf_TableCell(__('Switches')); if ($this->ponFlag) { $cells .= wf_TableCell(__('PON ONU')); } if ($this->docsisFlag) { $cells .= wf_TableCell(__('DOCSIS Modems')); } $rows = wf_TableRow($cells, 'row1'); foreach ($yearData as $monthNum => $each) { $cells = wf_TableCell($months[$monthNum]); $cells .= wf_TableCell($each['e_switches']); if ($this->ponFlag) { $cells .= wf_TableCell($each['e_pononu']); } if ($this->docsisFlag) { $cells .= wf_TableCell($each['e_docsis']); } $rows .= wf_TableRow($cells, 'row3'); //chart data $equipChartData[] = array($months[$monthNum], $each['e_switches'], $each['e_pononu'], $each['e_docsis']); } $result .= wf_TableBody($rows, '100%', 0, ''); if ($chartsFlag) { $result .= wf_gchartsLine($equipChartData, __('Equipment'), '100%', '300px', $chartsOptions); } } else { $result .= $this->messages->getStyledMessage(__('Nothing found'), 'info'); } return $result; }