| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <?php
- Lib::loadClass('PHPGraphLib');
- function GRAPH() {
- $type = V::get('type', '', $_GET);
- switch ($type) {
- case 'TABLE':
- GRAPH_table();
- break;
- case 'HOUR':
- GRAPH_hour();
- break;
- default:
- GRAPH_default();
- }
- }
- function GRAPH_RandomColorGenerator(){
- //global $red, $green, $blue, $color;
- $color = array(rand(50,255), rand(50,255), rand(50,255)); //generates random RGB color;
- $red = $color[0]; //red value;
- $green = $color[1]; //green value;
- $blue = $color[2]; //blue value;
- $ret=$red.",".$green.",".$blue;
- // $ret="255,5,5";
- return($ret);
- }
- function GRAPH_table() {
- //$ARR['DATE_CHART'][$DWA->C2][$DWA->C1_Y][$DWA->C1_M][$DWA->C1_D]++;
- foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $C2=>$C2V) {
- $i=0;
- // echo "\n wstawiam dla C2 ".$C2." dane ".$C2V;
- // $data_color[$C2]=GRAPH_RandomColorGenerator();
- foreach($C2V as $C1_Y=>$C1_YV) {
- // echo "\n wstawiam dla C1_Y ".$C1_Y." dane ".$C1_YV;
- foreach($C1_YV as $C1_M=>$C1_MV) {
- // echo "\n wstawiam dla C1_M ".$C1_M." dane ".$C1_MV;
- foreach($C1_MV as $C1_D=>$C1_DV) {
-
- // echo "\n wstawiam dla ".$C1_MV." dane ".$C1_DV;
- $data[$C2][substr($C1_Y,-2)."-".$C1_M."-".$C1_D]=$C1_DV['COUNT'];
- // $data_hrs[$C2][substr($C1_Y,-2)."-".$C1_M."-".$C1_D]=$C1_DV;
- $i+=$C1_DV['COUNT'];
- //if($i>14) break;
-
- //hours
- foreach($C1_DV['TABLE'] as $C1_H=>$C1_HV) {
- //echo "\n wstawiam dla C1_H ".$C1_H." dane ".$C1_HV;
- $data_table[$C2][$C1_H]+=$C1_HV;
- }
- }
- }
-
- }
-
-
- // break;
- }
- /*
- $data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033,
- "5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024,
- "10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036,
- "14" => .0028, "15" => .0025);
- */
- foreach($data_table as $user_i=>$user) {
- foreach($user as $TABLEE_I=>$TABLE_V) {
- foreach($data_table as $test_user_i=>$test_user_v) {
- if(!isset($test_user_v[$TABLEE_I])) {
- //echo "\n W user ".$test_user_i." tabeli ".$TABLEE_I." brakuje!";
- $data_table[$test_user_i][$TABLEE_I]=0;
- }
- }
- }
- }
- foreach($data_table as $user_i=>$user) {
- //echo "\n data duuppa:\n".$user_i;
- ksort($data_table[$user_i]);
- }
- $graph=new PHPGraphLib(800,400);
- $graph->addData($data_table[$_GET['C2']]);
- // $graph->setBarColor(GRAPH_RandomColorGenerator());
- $graph->setBarColor("green");
- $graph->setLegendTitle($_GET['C2']);
- if ($_GET['C22']) {
- $graph->addData($data_table[$_GET['C22']]);
- //$graph->setBarColor(GRAPH_RandomColorGenerator());
- $graph->setBarColor("red");
- $graph->setLegendTitle($_GET['C22']);
- }
-
- $graph->setGoalLine(100,"green");
- $graph->setGoalLine(200,"red");
- //$graph->setGoalLineColor("red","green");
- //$graph->setTitle('Company Production');
- $graph->setupYAxis(12, 'blue');
- $graph->setupXAxis(20);
- $graph->setGrid(false);
- $graph->setLegend(true);
- $graph->setTitleLocation('left');
- $graph->setTitleColor('blue');
- $graph->setLegendOutlineColor('white');
- //$graph->setLegendTitle('Week-37', 'Week-38');
- $graph->setXValuesHorizontal(false);
- $graph->createGraph();
- }
- function GRAPH_hour() {
- //$ARR['DATE_CHART'][$DWA->C2][$DWA->C1_Y][$DWA->C1_M][$DWA->C1_D]++;
- foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $C2=>$C2V) {
- $i=0;
- // echo "\n wstawiam dla C2 ".$C2." dane ".$C2V;
- // $data_color[$C2]=RandomColorGenerator();
- foreach($C2V as $C1_Y=>$C1_YV) {
- // echo "\n wstawiam dla C1_Y ".$C1_Y." dane ".$C1_YV;
- foreach($C1_YV as $C1_M=>$C1_MV) {
- // echo "\n wstawiam dla C1_M ".$C1_M." dane ".$C1_MV;
- foreach($C1_MV as $C1_D=>$C1_DV) {
- // echo "\n wstawiam dla ".$C1_MV." dane ".$C1_DV;
- $data[$C2][substr($C1_Y,-2)."-".$C1_M."-".$C1_D]=$C1_DV['COUNT'];
- // $data_hrs[$C2][substr($C1_Y,-2)."-".$C1_M."-".$C1_D]=$C1_DV;
- $i+=$C1_DV['COUNT'];
- //if($i>14) break;
-
- //hours
- foreach($C1_DV['HOURS'] as $C1_H=>$C1_HV) {
- // echo "\n wstawiam dla C1_H ".$C1_H." dane ".$C1_HV;
- $data_hours[$C2][$C1_H]+=$C1_HV;
- }
- }
- }
- }
- // break;
- }
- /*
- $data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033,
- "5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024,
- "10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036,
- "14" => .0028, "15" => .0025);
- */
- //tabela z godzinami pracy
- foreach($data_hours as $user_i=>$user) {
- foreach($user as $TABLEE_I=>$TABLE_V) {
- foreach($data_hours as $test_user_i=>$test_user_v) {
- if(!isset($test_user_v[$TABLEE_I])) {
- //echo "\n W user ".$test_user_i." tabeli ".$TABLEE_I." brakuje!";
- $data_hours[$test_user_i][$TABLEE_I]=0;
- }
- }
- }
- }
- foreach($data_hours as $user_i=>$user) {
- ksort($data_hours[$user_i]);
- }
- $graph=new PHPGraphLib(800,400);
- /*foreach($data as $data_add_i=>$data_add_v) {
- //$graph->addData($data['gubarewp']);
- if($data_size[$data_add_i]>50) {
- $graph->addData($data[$data_add_i]);
- $graph->setBarColor(RandomColorGenerator());
- // setLineColor("red");
- $graph->setLegendTitle(substr($data_add_i,0,5));
- }
- }
- */
- //$_GET['C2']=stripslashes($GET['C2']);
- $graph->addData($data_hours[$_GET['C2']]);
- //$graph->setBarColor(RandomColorGenerator());
- $graph->setBarColor('green');
- $graph->setLegendTitle($_GET['C2']);
- if($_GET['C22']) {
- $graph->addData($data_hours[$_GET['C22']]);
- // $graph->setBarColor(RandomColorGenerator());
- $graph->setBarColor('red');
- $graph->setLegendTitle($_GET['C22']);
- }
- $graph->setGoalLine(100,"green");
- $graph->setGoalLine(200,"red");
- //$graph->setGoalLineColor("red","green");
- //$graph->setTitle('Company Production');
- $graph->setupYAxis(12, 'blue');
- $graph->setupXAxis(20);
- $graph->setGrid(false);
- $graph->setLegend(true);
- $graph->setTitleLocation('left');
- $graph->setTitleColor('blue');
- $graph->setLegendOutlineColor('white');
- //$graph->setLegendTitle('Week-37', 'Week-38');
- $graph->setXValuesHorizontal(false);
- $graph->createGraph();
- }
- function GRAPH_default() {
- $_GET['C2'] = V::get('C2', '', $_GET);
- $_GET['C22'] = V::get('C22', '', $_GET);
- //$ARR['DATE_CHART'][$DWA->C2][$DWA->C1_Y][$DWA->C1_M][$DWA->C1_D]++;
- foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $C2=>$C2V) {
- $i=0;
- foreach($C2V as $C1_Y=>$C1_YV) {
- if (!is_array($C1_YV)) {
- continue;
- }
- foreach($C1_YV as $C1_M=>$C1_MV) {
- if (!is_array($C1_MV)) {
- continue;
- }
- foreach($C1_MV as $C1_D=>$C1_DV) {
- $data[$C2][substr($C1_Y,-2)."-".$C1_M."-".$C1_D]=$C1_DV['COUNT'];
- $i+=$C1_DV['COUNT'];
- }
- }
- }
- $_SESSION['CHART']['ARR']['DATE_CHART'][$C2]['SIZE']=$i;
- $data_size[$C2]=$i;
- }
- /*
- $data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033,
- "5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024,
- "10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036,
- "14" => .0028, "15" => .0025);
- */
- //Sortujemy i uzupelniamy daty prac o brakujace indeksy
- foreach ($_SESSION['CHART']['ARR']['DATE_CHART'] as $user_i=>$user) { //lecimy ARR[User]
- if (!is_array($user)) {
- continue;
- }
- foreach ($user as $TABLEE_I=>$TABLE_V) { //Lecimy ARR[User][Rok]
- if (!is_array($TABLE_V)) {
- continue;
- }
- foreach ($TABLE_V as $TABLEE_II=>$TABLE_VV) { //Lecimy ARR[User][Rok][m-c]
- if (!is_array($TABLE_VV)) {
- continue;
- }
- foreach ($TABLE_VV as $TABLEE_III=>$TABLE_VVV) { //Lecimy ARR[User][Rok][m-c][day]
- if (!is_array($TABLE_VVV)) {
- continue;
- }
- foreach ($_SESSION['CHART']['ARR']['DATE_CHART'] as $test_user_i=>$test_user_v) { //arr[user]
- if (!isset($test_user_v[$TABLEE_I][$TABLEE_II][$TABLEE_III])) {
- echo "\n W user ".$test_user_i." tabeli ".$TABLEE_I."-".$TABLEE_II."-".$TABLEE_III." brakuje!";
- $_SESSION['CHART']['ARR']['DATE_CHART'][$test_user_i][$TABLEE_I][$TABLEE_II][$TABLEE_III]['COUNT']=0;
- }
- }
- }
- }
- }
- }
- foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $user_i=>$user) { //lecimy ARR[User]
- ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i]);
- foreach($user as $TABLEE_I=>$TABLE_V) { //Lecimy ARR[User][Rok]
- if (!is_array($TABLE_V)) {
- continue;
- }
- ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i][$TABLEE_I]);
- foreach($TABLE_V as $TABLEE_II=>$TABLE_VV) { //Lecimy ARR[User][Rok][m-c]
- if (!is_array($TABLE_VV)) {
- continue;
- }
- ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i][$TABLEE_I][$TABLEE_II]);
- foreach($TABLE_VV as $TABLEE_III=>$TABLE_VVV) { //Lecimy ARR[User][Rok][m-c][day]
- ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i][$TABLEE_I][$TABLEE_II][$TABLEE_III]);
- }
- }
- }
- }
- $graph = new PHPGraphLib(800,400);
- /*foreach($data as $data_add_i=>$data_add_v) {
- //$graph->addData($data['gubarewp']);
- if($data_size[$data_add_i]>50) {
- $graph->addData($data[$data_add_i]);
- $graph->setBarColor(RandomColorGenerator());
- // setLineColor("red");
- $graph->setLegendTitle(substr($data_add_i,0,5));
- }
- }
- */
- //$_GET['C2']=stripslashes($GET['C2']);
- $graph->addData($data[$_GET['C2']]);
- $graph->setBarColor('green');
- // $graph->setBarColor(RandomColorGenerator());
- // setLineColor("red");
- $graph->setLegendTitle($_GET['C2']);
- if ($_GET['C22']) {
- $graph->addData($data[$_GET['C22']]);
- // $graph->setBarColor(RandomColorGenerator());
- $graph->setBarColor('red');
- // setLineColor("red");
- $graph->setLegendTitle($_GET['C22']);
- }
- $graph->setGoalLine(100,"green");
- $graph->setGoalLine(200,"red");
- //$graph->setGoalLineColor("red","green");
- //$graph->setTitle('Company Production');
- $graph->setupYAxis(12, 'blue');
- $graph->setupXAxis(20);
- $graph->setGrid(false);
- $graph->setLegend(true);
- $graph->setTitleLocation('left');
- $graph->setTitleColor('blue');
- $graph->setLegendOutlineColor('white');
- //$graph->setLegendTitle('Week-37', 'Week-38');
- $graph->setXValuesHorizontal(false);
- $graph->createGraph();
- }
- ?>
|