= '2010-01-01 00:00:00' AND jb.jb_finishtime <= '2010-01-31 23:59:59' GROUP BY jb.emp_id ORDER BY emp_id */ function htmlDivLineSpacerBlack ($height = "10px", $width = "", $clear = "") { global $constMenuBackground; if ($width == "") : $width = "100%"; endif; return "
"; } // Returns the statement to get the statistic of the sum of all jobs according to a specified datetime interval // ONE HEADQUARTERS function getCumulatedJobData ($fromDatetime, $toDatetime, $hqIds = "", $retMode = "0", $whereClause = "", $orderByClause = "") { global $db, $PHP_SELF; $retVal = ""; if ($fromDatetime != "" && $toDatetime != "") : $whereClauseHq = ""; if ($hqIds != "") : $whereClauseHq = " AND jb.hq_id IN (" . $hqIds . ") "; endif; if ($whereClause != "") : $whereClause = " AND " . $whereClause; endif; if ($orderByClause == "") : $orderByClause = "count_jobs"; endif; $sqlquery = "SELECT count(jb.jb_id) AS count_jobs, SUM(jb.jb_totalprice) as business_volume" . " FROM job AS jb" . " WHERE jb.jb_status = '2' " . $whereClauseHq . " AND " . " (isnull(jb.jb_storno) OR jb.jb_storno = '0' OR jb.jb_storno = '1' OR jb.jb_storno = '3') AND" . " jb.jb_finishtime >= '" . $fromDatetime . "' AND" . " jb.jb_finishtime <= '" . $toDatetime . "'" . $whereClause . " ORDER BY " . $orderByClause; if ($retMode == "0") : return $sqlquery; endif; // Execute statement $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $count_jobs = $row["count_jobs"]; $business_volume = $row["business_volume"]; endwhile; $result->free(); if ($retMode == "1") : $retVal = array($count_jobs, $business_volume); endif; if ($retMode == "2") : $retVal = $count_jobs; endif; if ($retMode == "3") : $retVal = round($business_volume, 2); endif; endif; return $retVal; } // Returns the statement to get the statistic of the sum of all jobs according to a specified datetime interval function getCumulatedJobDataMultiHeadquarters ($fromDatetime, $toDatetime, $whereClause = "", $orderByClause = "", $excludedHQs) { global $db, $PHP_SELF; $retVal = ""; if ($fromDatetime != "" && $toDatetime != "") : $whereClauseHq = ""; if ($excludedHQs != "") : $whereClauseHq = " AND jb.hq_id NOT IN (" . $excludedHQs . ") "; endif; if ($whereClause != "") : $whereClause = " AND " . $whereClause; endif; if ($orderByClause == "") : $orderByClause = "count_jobs"; endif; $sqlquery = "SELECT count(jb.jb_id) AS count_jobs, SUM(jb.jb_totalprice) as business_volume, hq.hq_id, hq.hq_mnemonic" . " FROM job AS jb, headquarters AS hq" . " WHERE jb.jb_status = '2'" . $whereClauseHq . " AND " . " (isnull(jb.jb_storno) OR jb.jb_storno = '0' OR jb.jb_storno = '1' OR jb.jb_storno = '3') AND" . " jb.jb_finishtime >= '" . $fromDatetime . "' AND" . " jb.jb_finishtime <= '" . $toDatetime . "'" . $whereClause . " AND" . " jb.hq_id = hq.hq_id" . " GROUP BY jb.hq_id" . " ORDER BY " . $orderByClause; // Execute statement $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $hq_mnemonic = array(); $count_jobs = array(); $business_volume = array(); while ($row = $result->fetch_assoc()): $hq_mnemonic[$row["hq_id"]] = $row["hq_mnemonic"]; $count_jobs[$row["hq_id"]] = $row["count_jobs"]; $business_volume[$row["hq_id"]] = $row["business_volume"]; endwhile; $result->free(); $retVal = array($hq_mnemonic, $count_jobs, $business_volume); endif; return $retVal; } // Set color of the difference amount function getColorOfAmount ($percentValue) { $colorOfBalanceDue = "#FF0000"; if ($percentValue >= 100) : $colorOfBalanceDue = "#00FF00"; elseif ($percentValue < 10) : $colorOfBalanceDue = "#FF2200"; elseif ($percentValue >= 10 && $percentValue < 20) : $colorOfBalanceDue = "#FF5500"; elseif ($percentValue >= 20 && $percentValue < 30) : $colorOfBalanceDue = "#FF9900"; elseif ($percentValue >= 30 && $percentValue < 40) : $colorOfBalanceDue = "#FFCC00"; elseif ($percentValue >= 40 && $percentValue < 50) : $colorOfBalanceDue = "#FFFF00"; elseif ($percentValue >= 50 && $percentValue < 60) : $colorOfBalanceDue = "#CCFF00"; elseif ($percentValue >= 60 && $percentValue < 70) : $colorOfBalanceDue = "#99FF00"; elseif ($percentValue >= 70 && $percentValue < 80) : $colorOfBalanceDue = "#55FF00"; elseif ($percentValue >= 80 && $percentValue < 90) : $colorOfBalanceDue = "#22FF00"; elseif ($percentValue >= 90 && $percentValue < 100) : $colorOfBalanceDue = "#00FF00"; endif; return $colorOfBalanceDue; }; $currentYear = getDateTime("year"); $currentMonth = getDateTime("month"); $currentDay = getDateTime("day"); $fromDatetime = $currentYear . "-" . $currentMonth . "-01 00:00:00"; $toDatetime = $currentYear . "-" . $currentMonth . "-" . $currentDay . " 23:59:59"; // *** STORE DATA BEGIN *** if ($f_act == "storeAmount") : // Check for password $parMotivationcounterPassword = getParameterValue("0", "MOTIVATIONCOUNTER_PASSWORD", $f_hq_id); if ($parMotivationcounterPassword != "" && $parMotivationcounterPassword == $f_password) : // Check for selected year and month if ($f_year != "" && $f_month != "") : $f_month = pad($f_month, 2); // Check for not overwriting months before if ($f_year . $f_month >= $currentYear . $currentMonth) : if ($f_business_volume != "" && is_numeric($f_business_volume)) : $parKey = "MOTIVATIONCOUNTER_" . $f_year . "_" . $f_month; if (existsEntry("parameter",array("par_key",$parKey,"emp_id","0","hq_id",$f_hq_id))) : updateStmt("parameter", "emp_id", "0", array("par_value", $f_business_volume), " par_key = '" . $parKey . "' AND hq_id = '" . $f_hq_id . "'"); else: insertStmt("parameter", array("par_key", $parKey, "emp_id", "0", "par_value", $f_business_volume, "hq_id", $f_hq_id)); endif; $f_year = ""; $f_month = ""; else : $statusMessage = "Sie müssen bitte auch einen Betrag eingeben!"; endif; else : $statusMessage = "Ältere Monate dürfen nicht überschrieben werden!"; endif; endif; else : $statusMessage = "Das Passwort ist nicht korrekt!"; endif; endif; if ($f_act == "listAmounts") : // Check for password $parMotivationcounterPassword = getParameterValue("0", "MOTIVATIONCOUNTER_PASSWORD", $hq_id); if ($parMotivationcounterPassword != "" && $parMotivationcounterPassword == $f_password) : // Get all parameters "MOTIVATIONCOUNTER_YYYY_mm" in database for the current headquarters $sqlquery = "SELECT par.par_key, par.par_value FROM parameter AS par" . " WHERE par.par_key LIKE 'MOTIVATIONCOUNTER_2%' AND" . " par.hq_id = '". $hq_id . "' AND" . " par.emp_id = '0'" . " ORDER BY par.par_key"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $insertFlag = TRUE; while ($row = $result->fetch_assoc()): $listOfAmounts .= "\n"; $listOfAmounts .= "" . substr($row["par_key"], 18, 4) . "\n"; // Year extracted out of par_key $listOfAmounts .= "" . substr($row["par_key"], 23, 2) . "\n"; // Month extracted out of par_key $listOfAmounts .= "" . number_format($row["par_value"], 2, ",", ".") . "\n"; $listOfAmounts .= "\n"; endwhile; if ($listOfAmounts != "") : $listOfAmounts = "


\n" . "\n" . $listOfAmounts . "
 Jahr  Monat  Soll 
\n"; endif; $result->free(); else : $statusMessage = "Das Passwort ist nicht korrekt!"; endif; endif; // *** STORE DATA END *** // Check for output mode for only one headquarters or for all headquarters with exceptions $parMotivationCounterMode = getParameterValue("0", "MOTIVATIONCOUNTER_MODE", "0"); if ($parMotivationCounterMode == "") : $parMotivationCounterMode = "0"; endif; if ($parMotivationCounterMode == "0") : // SINGLE HEADQUARTERS // Get business volume of the current month done by finished jobs $businessVolume = getCumulatedJobData($fromDatetime, $toDatetime, $hq_id, "3", "", ""); $businessVolumeOut = number_format($businessVolume, 2, ",", "."); // Get presetting set by leader $parBusinessVolumeCurrentMonth = getParameterValue("0", "MOTIVATIONCOUNTER_" . $currentYear . "_" . $currentMonth, $hq_id); if ($parBusinessVolumeCurrentMonth == "") : $parBusinessVolumeCurrentMonth = 0; endif; $parBusinessVolumeCurrentMonth = round($parBusinessVolumeCurrentMonth, 2); $parBusinessVolumeCurrentMonthOut = number_format($parBusinessVolumeCurrentMonth, 2, ",", "."); // Difference amount $balanceDue = ($parBusinessVolumeCurrentMonth - $businessVolume); $balanceDue = round($balanceDue,2); if ($balanceDue < 0) : $balanceDue = $balanceDue * (-1); $balanceDueOut = number_format($balanceDue, 2, ",", "."); $balanceDueOut = "+ " . $balanceDueOut; else : $balanceDueOut = number_format($balanceDue, 2, ",", "."); endif; // Percent value $percentValue = 0; $colorOfBalanceDue = getColorOfAmount ($percentValue); $percentValueOut = ""; if ($parBusinessVolumeCurrentMonth != "0") : $percentValue = (($businessVolume / $parBusinessVolumeCurrentMonth) * 100); $percentValue = round($percentValue,2); $colorOfBalanceDue = getColorOfAmount ($percentValue); $percentValueOut = "
" . "[ " . number_format($percentValue, 2, ",", ".") . " % erreicht ]" . "
"; endif; // Percent value bar $tmpPercentValue = round(($percentValue * 4),0); $tmpPercentValue2 = (400 - $tmpPercentValue); $percentValueBarOut .= ""; $percentValueBarOut .= ""; else : // MULTI HEADQUARTERS // Get business volume of the current month done by finished jobs $multiArray = getCumulatedJobDataMultiHeadquarters($fromDatetime, $toDatetime, "", "", "203"); $hqMnemonicArray = $multiArray[0]; $countJobsArray = $multiArray[1]; $businessVolumeArray = $multiArray[2]; // Business volume of the current headquarters $businessVolume = round($businessVolumeArray[$hq_id], 2); $businessVolumeOut = number_format($businessVolumeArray[$hq_id], 2, ",", "."); $parBusinessVolumeCurrentMonthArray = array(); $percentValueArray = array(); $outArray = array(); $tmpKeys = array_keys($businessVolumeArray); // Headquarters IDs $tmpKeysLen = count($tmpKeys); for ($i = 0; $i < $tmpKeysLen; $i++) : $currHqId = $tmpKeys[$i]; // Get presetting set by leader $parBusinessVolumeCurrentMonth = getParameterValue("0", "MOTIVATIONCOUNTER_" . $currentYear . "_" . $currentMonth, $currHqId); if ($parBusinessVolumeCurrentMonth == "") : $parBusinessVolumeCurrentMonth = 0; endif; $parBusinessVolumeCurrentMonthArray[$currHqId] = round($parBusinessVolumeCurrentMonth, 2); // Percent value $percentValue = 0; if ($parBusinessVolumeCurrentMonth != "0") : $percentValue = (($businessVolumeArray[$currHqId] / $parBusinessVolumeCurrentMonth) * 100); $percentValue = round($percentValue,2); endif; if ($currHqId == $hq_id) : $colorOfBalanceDue = getColorOfAmount($percentValue); $parBusinessVolumeCurrentMonthOut = number_format($parBusinessVolumeCurrentMonth, 2, ",", "."); endif; // Percent value bar $tmpPercentValue = round(($percentValue * 4),0); $tmpPercentValue2 = (400 - $tmpPercentValue); $outArray[$currHqId] = "" . $hqMnemonicArray[$currHqId] . "   " . "" . "   " . number_format($percentValue, 2, ",", ".") . " %\n"; endfor; // Sort and output of all bars $percentValueBarOut .= ""; $percentValueBarOut .= $outArray[$hq_id]; $percentValueBarOut .= ""; for ($i = 0; $i < $tmpKeysLen; $i++) : $currHqId = $tmpKeys[$i]; if ($currHqId != $hq_id) : $percentValueBarOut .= $outArray[$currHqId]; endif; endfor; $percentValueBarOut .= "
< >
"; // Do not show the single percent value $percentValueOut = ""; // Difference amount $balanceDue = ($parBusinessVolumeCurrentMonthArray[$hq_id] - $businessVolume); $balanceDue = round($balanceDue,2); if ($balanceDue < 0) : $balanceDue = $balanceDue * (-1); $balanceDueOut = number_format($balanceDue, 2, ",", "."); $balanceDueOut = "+ " . $balanceDueOut; else : $balanceDueOut = number_format($balanceDue, 2, ",", "."); endif; endif; // Output if ($f_year == "") : $f_year = $currentYear; endif; if ($f_month == "") : $f_month = $currentMonth; endif; ?>
padding: 0px; margin: 0px; border: 0px; outline: 0px; background:#000000; text-align:center; vertical-align:middle;">
 €
SOLL:    €          IST:    €
         Betrag: (Liste)    Passwort:     Speichern