index.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. if ($system->checkForRight('EMPLOYEE')) {
  3. /**
  4. * Returns month stats per employee done jobs
  5. *
  6. * @return string
  7. */
  8. function ts_EmployeeMonthGraphs() {
  9. $curmonth = curmonth();
  10. $employees = ts_GetAllEmployee();
  11. $month_jobs_q = "SELECT `workerid`,`jobid` from `jobs` WHERE `date` LIKE '" . $curmonth . "%'";
  12. $alljobs = simple_queryall($month_jobs_q);
  13. $jobtypes = ts_GetAllJobtypes();
  14. $jobdata = array();
  15. $result = '';
  16. if (!empty($employees)) {
  17. if (!empty($alljobs)) {
  18. foreach ($alljobs as $io => $eachjob) {
  19. if (isset($jobdata[$eachjob['workerid']][$eachjob['jobid']])) {
  20. $jobdata[$eachjob['workerid']][$eachjob['jobid']] ++;
  21. } else {
  22. $jobdata[$eachjob['workerid']][$eachjob['jobid']] = 1;
  23. }
  24. }
  25. }
  26. //build graphs for each employee
  27. if (!empty($jobdata)) {
  28. foreach ($jobdata as $employee => $each) {
  29. $employeeName = isset($employees[$employee]) ? $employees[$employee] : __('Deleted');
  30. $result.=wf_tag('h3', false) . $employeeName . wf_tag('h3', true);
  31. $rows = '';
  32. if (!empty($each)) {
  33. foreach ($each as $jobid => $count) {
  34. $cells = wf_TableCell(@$jobtypes[$jobid], '40%');
  35. $cells.=wf_TableCell($count, '20%');
  36. $cells.=wf_TableCell(web_bar($count, sizeof($alljobs)), '40%');
  37. $rows.=wf_TableRow($cells, 'row3');
  38. }
  39. }
  40. $result.=wf_TableBody($rows, '100%', 0);
  41. $result.=wf_delimiter();
  42. }
  43. }
  44. }
  45. return ($result);
  46. }
  47. $jobgraphs = wf_modal(wf_img('skins/icon_stats.gif', __('Graphs')), __('Graphs'), ts_EmployeeMonthGraphs(), '', '800', '600');
  48. $donejobs = ts_JGetJobsReport();
  49. show_window(__('Job report') . ' ' . $jobgraphs, wf_FullCalendar($donejobs));
  50. } else {
  51. show_error(__('Access denied'));
  52. }
  53. ?>