"; $debug = true; endif; $debugOverwritePercentValue = ""; if ($debug) : $debugOverwritePercentValue = ""; endif; // Parameters $f_business_volume = str_replace (",", ".", $f_business_volume); $listOfAmounts = ""; if ($f_hqId == "") : $f_hqId = $hq_id; endif; // Hide or show output of business volume // $parMotivationCounterViewmodeBusinessVolume = getParameterValue("0", "MOTIVATIONCOUNTER_VIEWMODE_BUSINESS_VOL", "0"); // if ($parMotivationCounterViewmodeBusinessVolume == "") : $parMotivationCounterViewmodeBusinessVolume = "0"; endif; if ($businessVolumeViewMode == "" || count($businessVolumeViewMode) == 0) : $parMotivationCounterViewmodeBusinessVolume = "0"; else : $parMotivationCounterViewmodeBusinessVolume = "1"; $businessVolumeViewMode = "1"; endif; // Selected headquarters regarding the multiple headquarters view if ($f_sel_hq_id == "") : $f_sel_hq_id = getColVectorFromDB2ArrayByClause("mandatorheadquarters AS mdhq, headquarters AS hq", "hq.hq_id", "mdhq.md_id = '" . $md_id . "' AND mdhq.hq_id = hq.hq_id", "", "hq.hq_mnemonic", ""); endif; if (count($f_sel_hq_id) == 0) : array_push($f_sel_hq_id, $hq_id); endif; // Current number of headquarters $numOfSelHq = getCountOfTable("headquarters"); // Mode of view (single headquarters only or all headquarters) if (!isset($viewMode) || $viewMode == "") : $viewMode = "0"; endif; $viewMode_0 = ""; $viewMode_1 = ""; if ($viewMode == "0") : $viewMode_0 = "checked"; endif; if ($viewMode == "1") : $viewMode_1 = "checked"; endif; /* // Nach Mitarbeiter gesplittet SELECT count(jb.jb_id) AS count_jobs, SUM(jb.jb_totalprice) as business_volume, jb.emp_id FROM job AS jb WHERE jb.jb_status = '2' AND jb.hq_id IN (2) AND (isnull(jb.jb_storno) OR jb.jb_storno = '0' OR jb.jb_storno = '1' OR jb.jb_storno = '3') AND jb.jb_finishtime >= '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 "
"; } // Gets checkboxes with headquarters function getSelectionHeadquartersCheckboxes($f_sel_hq_id, $numOfSelHq) { $phpHeadquartersOut = ""; if ($numOfSelHq != "" && is_numeric($numOfSelHq) && $numOfSelHq > 0) : $phpHeadquartersOut .= "
"; $phpHeadquartersOut .= addCheckboxesFromTable("f_sel_hq_id","headquarters","hq_id","hq_mnemonic","hq_mnemonic","",$f_sel_hq_id, "   ",""); $phpHeadquartersOut .= "
"; $phpHeadquartersOut .= htmlDivLineSpacerBlack("10px"); $phpHeadquartersOut .= defineButtonType10(getLngt("Alle"), "f_hq_sel_check_all", "hqSelectionCheckAll(" . $numOfSelHq . ");", "50px"); $phpHeadquartersOut .= htmlDivLineSpacerBlack("5px"); $phpHeadquartersOut .= defineButtonType10(getLngt("Keine"), "f_hq_sel_uncheck_all", "hqSelectionUncheckAll(" . $numOfSelHq . ");", "50px"); $phpHeadquartersOut .= htmlDivLineSpacerBlack("5px"); $phpHeadquartersOut .= defineButtonType10(getLngt("Aktualisieren"), "f_hq_sel_submit", "finishPage('');", "100px"); $phpHeadquartersOut .= htmlDivLineSpacerBlack("10px", "", "left"); endif; return $phpHeadquartersOut; } // 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; global $debug; $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; // Exclude jobs for special customers $whereClauseExcludedCustomers = getParameterValue("0", "MOTIVATIONCOUNTER_EXCLUDED_CS", "0"); $whereClauseExcludedCustomers = trim($whereClauseExcludedCustomers); if ($whereClauseExcludedCustomers != "") : $tmpArray = spliti(",", $whereClauseExcludedCustomers); $whereClauseExcludedCustomers = " AND cs.cs_eid NOT IN ('" . implode("','", $tmpArray) . "')"; 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; */ $sqlquery = "SELECT count(jb.jb_id) AS count_jobs, SUM(jb.jb_totalprice) as business_volume" . " FROM job AS jb, costcenter AS csc, customer AS cs" . " 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 . "' AND" . " jb.csc_id_payer = csc.csc_id AND" . " csc.cs_id = cs.cs_id" . $whereClauseExcludedCustomers . $whereClause . " ORDER BY " . $orderByClause; if ($debug) : echo "

" . $sqlquery . "

"; endif; 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, $f_sel_hq_id) { 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; // Exclude jobs for special customers $whereClauseExcludedCustomers = getParameterValue("0", "MOTIVATIONCOUNTER_EXCLUDED_CS", "0"); $whereClauseExcludedCustomers = trim($whereClauseExcludedCustomers); if ($whereClauseExcludedCustomers != "") : $tmpArray = spliti(",", $whereClauseExcludedCustomers); $whereClauseExcludedCustomers = " AND cs.cs_eid NOT IN ('" . implode("','", $tmpArray) . "')"; 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; */ $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, costcenter AS csc, customer AS cs" . " WHERE jb.jb_status = '2' AND" . " jb.hq_id IN " . getSQLMandatorArray($f_sel_hq_id) . " AND" . " jb.hq_id = hq.hq_id" . $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 . "' AND" . " jb.csc_id_payer = csc.csc_id AND" . " csc.cs_id = cs.cs_id" . $whereClauseExcludedCustomers . $whereClause . " GROUP BY hq.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, $displayMode = "") { global $debugOverwritePercentValue; if ($debugOverwritePercentValue != "") : $percentValue = $debugOverwritePercentValue; endif; if ($displayMode == "1") : $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; elseif ($displayMode == "2") : $colorOfBalanceDue = "#FF0000"; if ($percentValue >= 100) : $colorOfBalanceDue = "#00FF00"; elseif ($percentValue < 10) : $colorOfBalanceDue = "#FF0000"; elseif ($percentValue >= 10 && $percentValue < 90) : $colorOfBalanceDue = "#FF0000"; elseif ($percentValue >= 90 && $percentValue < 95) : $colorOfBalanceDue = "#FFFF00"; elseif ($percentValue >= 95 && $percentValue < 100) : $colorOfBalanceDue = "#00FF00"; endif; else : $colorOfBalanceDue = "#FF0000"; if ($percentValue >= 100) : $colorOfBalanceDue = "#00FF00"; elseif ($percentValue < 10) : $colorOfBalanceDue = "#FF0000"; elseif ($percentValue >= 10 && $percentValue < 90) : $colorOfBalanceDue = "#FF0000"; elseif ($percentValue >= 90 && $percentValue < 95) : $colorOfBalanceDue = "#FFFF00"; elseif ($percentValue >= 95 && $percentValue < 100) : $colorOfBalanceDue = "#00FF00"; endif; endif; return $colorOfBalanceDue; }; // Define output of the percent value bar function getBarOutput($percentValue, $displayMode = "") { global $debugOverwritePercentValue; if ($debugOverwritePercentValue != "") : $percentValue = $debugOverwritePercentValue; endif; $tmpPercentValue = round(($percentValue * 4),0); $percentValueBarOut = ""; if ($percentValue > 100) : $percentValue = 100; endif; if ($displayMode == "1") : $tmpPercentValue = round(($percentValue * 4),0); $tmpPercentValue2 = (400 - $tmpPercentValue); $percentValueBarOut .= ""; $percentValueBarOut .= ""; elseif ($displayMode == "2") : $widthRed = round((min($percentValue,90) * 4),0); $widthYellow = 0; if ($percentValue >= 90) : $widthYellow = round((min(($percentValue - 90),5) * 4),0); endif; $widthGreen = 0; if ($percentValue >= 95) : $widthGreen = round((min(($percentValue - 95),5) * 4),0); endif; $widthGray = round(((100 - $percentValue) * 4),0); $percentValueBarOut .= ""; $percentValueBarOut .= ""; $percentValueBarOut .= ""; $percentValueBarOut .= ""; else : $widthBar = round((min($percentValue,90) * 4),0); $colBar = "spacer_red.jpg"; if ($percentValue >= 90) : $colBar = "spacer_yellow.jpg"; endif; if ($percentValue >= 95) : $colBar = "spacer_green.jpg"; endif; $widthGray = round(((100 - $percentValue) * 4),0); $percentValueBarOut .= ""; $percentValueBarOut .= ""; endif; return $percentValueBarOut; } $nameOfMonths = array("Jan.", "Feb.", "März", "April", "Mai", "Juni", "Juli", "Aug.", "Sept.", "Okt.", "Nov.", "Dez.", ); $currentYear = getDateTime("year"); $currentMonth = getDateTime("month"); $currentDay = getDateTime("day"); $nameOfCurrentMonth = $nameOfMonths[($currentMonth - 1)]; $fromDatetime = $currentYear . "-" . $currentMonth . "-01 00:00:00"; $toDatetime = $currentYear . "-" . $currentMonth . "-" . $currentDay . " 23:59:59"; $parMotivationCounterPreviousMonth = ""; if ($currentDay < 10) : $parMotivationCounterPreviousMonth = getParameterValue("0", "MOTIVATIONCOUNTER_PREVIOUS_MONTH", "0"); if ($viewMode == "1") : $parMotivationCounterPreviousMonth = ""; endif; // Disable if multi headquarters view if ($parMotivationCounterPreviousMonth == "1") : $firstDayOfLastMonth = date("Ym", mktime(0,0,0,date("m")-1,1,date("Y"))); $lastMonth = substr($firstDayOfLastMonth, 4, 2); $yearOfLastMonth = substr($firstDayOfLastMonth, 0, 4); $lastDayOfLastMonth = $calMonthDays[($lastMonth - 1)]; $nameOfLastMonth = $nameOfMonths[($lastMonth - 1)]; $fromDatetimeLastMonth = $yearOfLastMonth . "-" . $lastMonth . "-01 00:00:00"; $toDatetimeLastMonth = $yearOfLastMonth . "-" . $lastMonth . "-" . $lastDayOfLastMonth . " 23:59:59"; endif; endif; // *** STORE DATA BEGIN *** if ($f_act == "storeAmount") : // Check for password $parMotivationcounterPassword = getParameterValue("0", "MOTIVATIONCOUNTER_PASSWORD", $f_hqId); 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_hqId))) : updateStmt("parameter", "emp_id", "0", array("par_value", $f_business_volume), " par_key = '" . $parKey . "' AND hq_id = '" . $f_hqId . "'"); else: insertStmt("parameter", array("par_key", $parKey, "emp_id", "0", "par_value", $f_business_volume, "hq_id", $f_hqId)); 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 // If parameter is defined, only this specified mode will be used. Otherwise the selected viewmode by the user will be used $parMotivationCounterMode = getParameterValue("0", "MOTIVATIONCOUNTER_MODE", "0"); if ($parMotivationCounterMode == "") : $parMotivationCounterMode = $viewMode; endif; if ($parMotivationCounterMode == "") : $parMotivationCounterMode = "0"; endif; if ($parMotivationCounterMode != "1") : // SINGLE HEADQUARTERS // Get values of the LAST MONTH if requested if ($parMotivationCounterPreviousMonth == "1") : $businessVolumeLastMonth = getCumulatedJobData($fromDatetimeLastMonth, $toDatetimeLastMonth, $hq_id, "3", "", ""); $businessVolumeLastMonthOut = number_format($businessVolumeLastMonth, 2, ",", "."); $parBusinessVolumeLastMonth = getParameterValue("0", "MOTIVATIONCOUNTER_" . $yearOfLastMonth . "_" . $lastMonth, $hq_id); if ($parBusinessVolumeLastMonth == "") : $parBusinessVolumeLastMonth = 0; endif; $parBusinessVolumeLastMonth = round($parBusinessVolumeLastMonth, 2); $parBusinessVolumeLastMonthOut = number_format($parBusinessVolumeLastMonth, 2, ",", "."); // Difference amount $balanceDueLastMonth = ($parBusinessVolumeLastMonth - $businessVolumeLastMonth); $balanceDueLastMonth = round($balanceDueLastMonth,2); if ($balanceDueLastMonth < 0) : $balanceDueLastMonth = $balanceDueLastMonth * (-1); $balanceDueLastMonthOut = number_format($balanceDueLastMonth, 2, ",", "."); $balanceDueLastMonthOut = "+ " . $balanceDueLastMonthOut; else : $balanceDueLastMonthOut = number_format($balanceDueLastMonth, 2, ",", "."); endif; // Percent value $percentValueLastMonth = 0; $colorOfBalanceDueLastMonth = getColorOfAmount ($percentValueLastMonth); $percentValueLastMonthOut = ""; if ($parBusinessVolumeLastMonth != "0") : $percentValueLastMonth = (($businessVolumeLastMonth / $parBusinessVolumeLastMonth) * 100); $percentValueLastMonth = round($percentValueLastMonth, 2); $colorOfBalanceDueLastMonth = getColorOfAmount ($percentValueLastMonth); $percentValueLastMonthOut = "
" . "[ " . number_format($percentValueLastMonth, 2, ",", ".") . " % erreicht ]" . "
"; endif; // Percent value bar $percentValueBarLastMonthOut = getBarOutput($percentValueLastMonth); endif; // Get values of the CURRENT MONTH // 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 $percentValueBarOut = getBarOutput($percentValue); else : // MULTI HEADQUARTERS // Get business volume of the current month done by finished jobs $multiArray = getCumulatedJobDataMultiHeadquarters($fromDatetime, $toDatetime, "", "", "203", $f_sel_hq_id); $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(); $parBusinessVolumeCallingHqCurrentMonth = getParameterValue("0", "MOTIVATIONCOUNTER_" . $currentYear . "_" . $currentMonth, $hq_id); if ($parBusinessVolumeCallingHqCurrentMonth == "") : $parBusinessVolumeCallingHqCurrentMonth = 0; endif; // Look for the own headquarters business volume before entering the loop to have an offset for displaying the bars only $parBusinessVolumeCurrentMonth = getParameterValue("0", "MOTIVATIONCOUNTER_" . $currentYear . "_" . $currentMonth, $hq_id); if ($parBusinessVolumeCurrentMonth == "") : $parBusinessVolumeCurrentMonth = 0; endif; $parBusinessVolumeCurrentMonth = round($parBusinessVolumeCurrentMonth, 2); $percentOffsetValueOfOwnHq = 0; if ($parBusinessVolumeCurrentMonth != 0) : $percentOffsetValueOfOwnHq = (($businessVolumeArray[$hq_id] / $parBusinessVolumeCurrentMonth) * 100); $percentOffsetValueOfOwnHq = round($percentOffsetValueOfOwnHq, 2); endif; $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; $percentValueDelta = ""; $percentValueDeltaAbsolute = ""; $percentValueDeltaRelative = ""; if ($parBusinessVolumeCurrentMonth != 0) : // Percent value for fulfilling the target (balance due) of each headquarters $percentValue = (($businessVolumeArray[$currHqId] / $parBusinessVolumeCurrentMonth) * 100); $percentValue = round($percentValue,2); // Percent value for comparison between the own headquarters regarding to the others using the business volumes $percentValueDelta = ((($businessVolumeArray[$currHqId] / $businessVolumeArray[$hq_id]) * 100) - 100); $percentValueDelta = round($percentValueDelta,2); // Percent value for absolute(!) comparison between the own headquarters regarding to the others $percentValueDeltaAbsolute = ((($businessVolumeArray[$hq_id] - $businessVolumeArray[$currHqId]) / $businessVolumeArray[$currHqId]) * 100); $percentValueDeltaAbsolute = round($percentValueDeltaAbsolute,2); // Percent value for relative(!) comparison between the own headquarters regarding to the others (=> better way to compare...) $percentValueDeltaRelative = 0; if ($parBusinessVolumeCallingHqCurrentMonth != "") : $percentValueDeltaRelative = ((($businessVolumeArray[$hq_id] / $parBusinessVolumeCallingHqCurrentMonth) * 100) - (($businessVolumeArray[$currHqId] / $parBusinessVolumeCurrentMonth) * 100)); $percentValueDeltaRelative = round($percentValueDeltaRelative,2); endif; 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); // Percent value bar $tmpPercentValueDelta = $tmpPercentValue * ($businessVolumeArray[$currHqId] / $businessVolumeArray[$hq_id]); $tmpPercentValueDelta2 = (400 - $tmpPercentValueDelta); // Percent value bar for absolute comparison /* $tmppercentValueDeltaAbsolute = ($percentValueDeltaAbsolute / 15); // Only for scaling the output $tmppercentValueDeltaAbsolute = round(($tmppercentValueDeltaAbsolute * 4),0); $tmppercentValueDeltaAbsolutePre = 200; $tmppercentValueDeltaAbsolutePost = 200; $outPercentBarImage = "spacer_green.jpg"; if ($tmppercentValueDeltaAbsolute >= 0) : $tmppercentValueDeltaAbsolutePost -= $tmppercentValueDeltaAbsolute; else : $tmppercentValueDeltaAbsolute = abs($tmppercentValueDeltaAbsolute); $tmppercentValueDeltaAbsolutePre -= $tmppercentValueDeltaAbsolute; $outPercentBarImage = "spacer_red.jpg"; endif; */ // Percent value bar for relative comparison /* $tmpPercentValueDeltaRelative = round(($percentValueDeltaRelative * 4),0); $tmpPercentValueDeltaRelative2 = (400 - $tmpPercentValueDeltaRelative); */ /* $outArray[$currHqId] = "" . $hqMnemonicArray[$currHqId] . "   " . "" . "   " . number_format($percentValue, 2, ",", ".") . " %\n"; */ $outArray[$currHqId] = "\n"; $outArray[$currHqId] .= "" . $hqMnemonicArray[$currHqId] . "   \n"; // Output bar for percent value // $outArray[$currHqId] .= "\n"; // Output bar for percent value of the comparison of the business volumes if ($currHqId == $hq_id) : $outArray[$currHqId] .= "\n"; else : $outArray[$currHqId] .= "\n"; endif; // Output bar for percent value of absolute comparison /* if ($currHqId == $hq_id) : $outArray[$currHqId] .= "\n"; else : // $outArray[$currHqId] .= "\n"; $outArray[$currHqId] .= "\n"; endif; */ // Output bar for percent value of relative comparison /* if ($currHqId == $hq_id) : $outArray[$currHqId] .= "\n"; else : $outArray[$currHqId] .= "\n"; endif; */ // The current business volume if ($parMotivationCounterViewmodeBusinessVolume == "0") : $outArray[$currHqId] .= "   " . number_format($businessVolumeArray[$currHqId], 2, ",", ".") . " €\n"; endif; // The debit of the month (balance due) // $outArray[$currHqId] .= "   [" . number_format($parBusinessVolumeCurrentMonth, 2, ",", ".") . " €]\n"; // Percent value for comparison between the headquarters regarding the business volumes if ($currHqId == $hq_id) : $outArray[$currHqId] .= "    \n"; else : $textColor = "color:#00FF00;"; if ($percentValueDelta < 0) : $textColor = "color:#FF0000;"; endif; $outArray[$currHqId] .= "   " . ($percentValueDelta != "" ? number_format(($percentValueDelta), 2, ",", ".") . " %" : "") . "\n"; endif; // Percent value for absolute(!) comparison between the headquarters /* if ($currHqId == $hq_id) : $outArray[$currHqId] .= "    \n"; else : $outArray[$currHqId] .= "   " . ($percentValueDeltaAbsolute != "" ? number_format(($percentValueDeltaAbsolute), 2, ",", ".") . " %" : "") . "\n"; endif; */ // Percent value for relative(!) comparison between the headquarters /* if ($currHqId == $hq_id) : $outArray[$currHqId] .= "   " . number_format($percentValue, 2, ",", ".") . " %\n"; else : $outArray[$currHqId] .= "   " . ($percentValueDeltaRelative != "" ? number_format(($percentValueDeltaRelative), 2, ",", ".") . " %" : "") . "\n"; endif; */ $outArray[$currHqId] .= "\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 .= "
< >
"; // Output of the percent value of the own headquarters $colorOfBalanceDue = getColorOfAmount ($percentValue); $percentValueOut = ""; if ($parBusinessVolumeCurrentMonthArray[$hq_id] != "0") : $percentValue = (($businessVolume / $parBusinessVolumeCurrentMonthArray[$hq_id]) * 100); $percentValue = round($percentValue,2); $colorOfBalanceDue = getColorOfAmount ($percentValue); $percentValueOut = "
" . number_format($percentValue, 2, ",", ".") . " %
"; endif; // 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:    €
padding: 0px; margin: 0px; border: 0px; outline: 0px; background:#000000; text-align:center; vertical-align:middle;">
" . $nameOfCurrentMonth . ":     "; endif; ?> €
SOLL:    €          IST:    €
onChange="javascript:finishPage('')">      onChange="javascript:finishPage('')">
         Betrag: (Liste)    Passwort:     Speichern