/** * Renders per-payment system openpayz transaction charts * * @return string */ public function renderGraphs() { $psysdata = array(); $gcAllData = array(); $gcMonthData = array(); $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-01", $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) { $gdata = __('Date') . ',' . __('Count') . ',' . __('Cash') . "\n"; foreach ($opdate as $datestamp => $optrans) { $gdata .= $datestamp . ',' . $optrans['count'] . ',' . $optrans['summ'] . "\n"; } $result .= wf_tag('div', false, '', ''); $result .= wf_tag('h2') . $psys . wf_tag('h2', true) . wf_delimiter(); $result .= wf_Graph($gdata, '800', '200', false); $result .= wf_tag('div', true); } } return $result; }
/** * Returns tariffs move report charts * * @return string */ function web_TariffShowTariffCharts() { $result = ''; $query = "SELECT `login`,`Tariff` from `users`"; $all = simple_queryall($query); $chartData = array(); if (!empty($all)) { foreach ($all as $io => $each) { if (isset($chartData[$each['Tariff']])) { $chartData[$each['Tariff']]++; } else { $chartData[$each['Tariff']] = 1; } } } if (!empty($chartData)) { $chartOpts = "chartArea: { width: '90%', height: '90%' }, legend : {position: 'right'}, "; $result .= wf_gcharts3DPie($chartData, __('Users'), '400px', '400px', $chartOpts); } return $result; }
/** * Renders payroll report search results for all employee * * @param string $datefrom * @param string $dateto * @return string */ public function payrollRenderSearchDate($datefrom, $dateto) { $datefrom = mysql_real_escape_string($datefrom); $dateto = mysql_real_escape_string($dateto); $result = ''; $totalSum = 0; $totalPayedSum = 0; $totalWage = 0; $totalBounty = 0; $totalWorkTime = 0; $jobCount = 0; $jobsTmp = array(); $employeeCharts = array(); $employeeChartsMoney = array(); $perEmployeeTimesheets = array(); $rangeTimesheets = $this->timesheetFilterDateRange($datefrom, $dateto); if (!empty($rangeTimesheets)) { foreach ($rangeTimesheets as $io => $each) { if (isset($perEmployeeTimesheets[$each['employeeid']])) { $perEmployeeTimesheets[$each['employeeid']] += $each['hours']; } else { $perEmployeeTimesheets[$each['employeeid']] = $each['hours']; } } } $query = "SELECT * from `salary_jobs` WHERE CAST(`date` AS DATE) BETWEEN '" . $datefrom . "' AND '" . $dateto . "';"; $all = simple_queryall($query); //jobs preprocessing if (!empty($all)) { foreach ($all as $io => $each) { $jobPrice = $this->getJobPrice($each['id']); $jobTime = isset($this->allJobTimes[$each['jobtypeid']]) ? $this->allJobTimes[$each['jobtypeid']] * $each['factor'] : 0; if (!isset($jobsTmp[$each['employeeid']])) { $payedSum = $each['state'] ? $jobPrice : 0; $jobsTmp[$each['employeeid']]['count'] = 1; $jobsTmp[$each['employeeid']]['sum'] = $jobPrice; $jobsTmp[$each['employeeid']]['payed'] = $payedSum; $jobsTmp[$each['employeeid']]['time'] = $jobTime; } else { $payedSum = $each['state'] ? $jobPrice : 0; $jobsTmp[$each['employeeid']]['count']++; $jobsTmp[$each['employeeid']]['sum'] += $jobPrice; $jobsTmp[$each['employeeid']]['payed'] += $payedSum; $jobsTmp[$each['employeeid']]['time'] += $jobTime; } $totalPayedSum += $payedSum; $totalSum += $jobPrice; } } $cells = wf_TableCell(__('Worker')); $cells .= wf_TableCell(__('Wage')); $cells .= wf_TableCell(__('Bounty')); $cells .= wf_TableCell(__('Work hours')); $cells .= wf_TableCell(__('Jobs')); $cells .= wf_TableCell(__('Spent time') . ' (' . __('hours') . ')'); $cells .= wf_TableCell(__('Earned money')); $cells .= wf_TableCell(__('Paid')); $rows = wf_TableRow($cells, 'row1'); if (!empty($this->allEmployee)) { foreach ($this->allEmployee as $io => $each) { $cells = wf_TableCell($each); $wage = isset($this->allWages[$io]['wage']) ? $this->allWages[$io]['wage'] : __('No'); $bounty = isset($this->allWages[$io]['bounty']) ? $this->allWages[$io]['bounty'] : __('No'); $worktime = isset($this->allWages[$io]['worktime']) ? $this->allWages[$io]['worktime'] : __('No'); $workerJobsData = isset($jobsTmp[$io]) ? $jobsTmp[$io] : array('count' => 0, 'sum' => 0, 'payed' => 0, 'time' => 0); $cells .= wf_TableCell($wage); $cells .= wf_TableCell($bounty); $cells .= wf_TableCell(@$perEmployeeTimesheets[$io]); $cells .= wf_TableCell($workerJobsData['count']); $cells .= wf_TableCell(round($workerJobsData['time'] / 60, 2)); $cells .= wf_TableCell($workerJobsData['sum']); $cells .= wf_TableCell($workerJobsData['payed']); $rows .= wf_TableRow($cells, 'row3'); $totalWage += $wage; $totalBounty += $bounty; $totalWorkTime += $workerJobsData['time']; $jobCount += $workerJobsData['count']; $employeeCharts[$each] = $workerJobsData['count']; $employeeChartsMoney[$each] = $workerJobsData['sum']; } } $cells = wf_TableCell(__('Total')); $cells .= wf_TableCell($totalWage); $cells .= wf_TableCell($totalBounty); $cells .= wf_TableCell(''); $cells .= wf_TableCell($jobCount); $cells .= wf_TableCell(round($totalWorkTime / 60, 2)); $cells .= wf_TableCell($totalSum); $cells .= wf_TableCell($totalPayedSum); $rows .= wf_TableRow($cells, 'row2'); $result = wf_TableBody($rows, '100%', 0, ''); $result .= wf_delimiter(); //charts $chartOpts = "chartArea: { width: '90%', height: '90%' }, legend : {position: 'right'},"; $sumCharts = array(__('Earned money') => $totalSum - $totalPayedSum, __('Paid') => $totalPayedSum); $cells = wf_TableCell(wf_gcharts3DPie($sumCharts, __('Money'), '400px', '400px', $chartOpts)); $cells .= wf_TableCell(wf_gcharts3DPie($employeeChartsMoney, __('Money') . ' / ' . __('Worker'), '400px', '400px', $chartOpts)); $rows = wf_TableRow($cells); $cells = wf_TableCell(wf_gcharts3DPie($employeeCharts, __('Jobs'), '400px', '400px', $chartOpts)); $cells .= wf_TableCell(''); $rows .= wf_TableRow($cells); $result .= wf_TableBody($rows, '100%', 0, ''); 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; }