Skip to content

Instantly share code, notes, and snippets.

@grgaortiz
Last active February 15, 2016 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grgaortiz/110f886459aab79c1306 to your computer and use it in GitHub Desktop.
Save grgaortiz/110f886459aab79c1306 to your computer and use it in GitHub Desktop.
Display method for pays comp table
public function displayCompensation($instanceDBInt, $clientID, $query, $specialtyGroups, $providers, $currentPeriod) {
// Open conn
$conn = $this->conn($clientID);
$periods = array(
'201601'
, '201602'
, '201603'
, '201604'
, '201605'
, '201606'
, '201607'
, '201608'
, '201609'
, '201610'
, '201611'
, '201612'
);
// Create tabel headers
$tableHeaders = "<td class='indent' style='font-weight:bold;text-align:left;'>Monthly Summary</td>";
$quarterCount = 1;
foreach ($periods AS $period) {
if ($quarterCount % 3 == 0) {
$tableHeaders .= "<td class='full' style='text-align:right;font-weight:bold;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;'>" . date("M 'y", strtotime($period . '01')) . "</td>";
} else {
$tableHeaders .= "<td class='full' style='text-align:right;font-weight:bold;'>" . date("M 'y", strtotime($period . '01')) . "</td>";
}
$quarterCount++;
}
$tableHeaders .= "<td class='border-right' style='text-align:right;font-weight:bold;'>YTD</td>";
// Quarterly Numbers
$quarterly_actualWRVUs = array();
$quarterly_earnedComp = array();
$quarterly_baseDraw = array();
// Get master comp data
$providers = str_replace('"', "'", $providers);
$providers = str_replace(" '", "", $providers);
$providers = str_replace("'", "", $providers);
$providers = str_replace('(', "PhysicianName_DWP LIKE '%", $providers);
$providers = str_replace(')', "%'", $providers);
$providerArray = explode("',", $providers);
$providers = implode("' OR ", $providerArray);
$providers = str_replace(array("\r", "\n"), "", $providers);
$providers = preg_replace('!\s+!', ' ', $providers);
if ($providers != '') {
$providers = 'AND (' . $providers . ')';
}
$specialtyGroups = str_replace('"', "'", $specialtyGroups);
$specialtyGroups = str_replace(" '", "", $specialtyGroups);
$specialtyGroups = str_replace("'", "", $specialtyGroups);
$specialtyGroups = str_replace('(', "SpecialtyGroup LIKE '%", $specialtyGroups);
$specialtyGroups = str_replace(')', "%'", $specialtyGroups);
$specialtyGroupsArray = explode("',", $specialtyGroups);
$specialtyGroups = implode("' OR ", $specialtyGroupsArray);
$specialtyGroups = str_replace(array("\r", "\n"), "", $specialtyGroups);
$specialtyGroups = preg_replace('!\s+!', ' ', $specialtyGroups);
if ($specialtyGroups == '') {
$specialtyGroups = "SpecialtyGroup != ''";
}
mssql_select_db('db_' . $clientID . '_WebData', $conn);
$compQuery = mssql_query("SELECT
AVG(QualityCompWithholdPercent) AS QualityCompWithholdPercent,
AVG(CAST(Tier1CFThreshold as int)) AS Tier1CFThreshold,
AVG(ThresholdCF) AS ThresholdCF,
AVG(DiscountCF) AS DiscountCF,
AVG(CAST(ProductionCompWithhold as money)) AS ProductionCompWithhold,
LEFT(CONVERT(varchar,MIN(CASE WHEN StartDate IS NULL THEN NULL ELSE StartDate END),112),6) AS StartDate,
MAX(CompPlanActive) AS CompPlanActive
FROM PhysicianComp WHERE year = '2016' AND (" . $specialtyGroups . ")
" . $providers . " ");
$row = mssql_fetch_array($compQuery);
$midlevelQuery = mssql_query("SELECT
ReportPeriod,
MidlevelExpense AS MidlevelExpense,
MidlevelProd AS MidlevelProd,
MonthlyMidlevel_Impactcurr AS MidlevelImpact,
QuarterlyMidlevel_Impactcurr AS QuarterlyMidlevelImpact,
QuarterlyTrueUpUpload,
MonthlyCFTThreshold
FROM PhysicianComp WHERE year = '2016' AND (" . $specialtyGroups . ")
" . $providers . " ");
$activeQueryLimit = '';
if ($row['CompPlanActive'] == '1') {
$activeQueryLimit = "CompPlanActive = '1' AND ";
}
$baseDrawQuery = mssql_query("SELECT
SUM(MonthlyClinicalBaseDraw) AS ClinicalBaseDraw
FROM PhysicianComp WHERE year = '2016' AND " . $activeQueryLimit . " (" . $specialtyGroups . ")
" . $providers . " ");
$baseDrawRow = mssql_fetch_array($baseDrawQuery);
$midlevelExpenseArray = array(
'201601' => '0'
, '201602' => '0'
, '201603' => '0'
, '201604' => '0'
, '201605' => '0'
, '201606' => '0'
, '201607' => '0'
, '201608' => '0'
, '201609' => '0'
, '201610' => '0'
, '201611' => '0'
, '201612' => '0'
);
$midlevelProdArray = array(
'201601' => '0'
, '201602' => '0'
, '201603' => '0'
, '201604' => '0'
, '201605' => '0'
, '201606' => '0'
, '201607' => '0'
, '201608' => '0'
, '201609' => '0'
, '201610' => '0'
, '201611' => '0'
, '201612' => '0'
);
$midlevelImpactArray = array(
'201601' => '0'
, '201602' => '0'
, '201603' => '0'
, '201604' => '0'
, '201605' => '0'
, '201606' => '0'
, '201607' => '0'
, '201608' => '0'
, '201609' => '0'
, '201610' => '0'
, '201611' => '0'
, '201612' => '0'
);
$midlevelQuarterlyImpactArray = array(
'201601' => '0'
, '201602' => '0'
, '201603' => '0'
, '201604' => '0'
, '201605' => '0'
, '201606' => '0'
, '201607' => '0'
, '201608' => '0'
, '201609' => '0'
, '201610' => '0'
, '201611' => '0'
, '201612' => '0'
);
$quarterlyTruUpPaidArray = array(
'201601' => '0'
, '201602' => '0'
, '201603' => '0'
, '201604' => '0'
, '201605' => '0'
, '201606' => '0'
, '201607' => '0'
, '201608' => '0'
, '201609' => '0'
, '201610' => '0'
, '201611' => '0'
, '201612' => '0'
);
$monthlyThresholdArray = array(
'201601' => '0'
, '201602' => '0'
, '201603' => '0'
, '201604' => '0'
, '201605' => '0'
, '201606' => '0'
, '201607' => '0'
, '201608' => '0'
, '201609' => '0'
, '201610' => '0'
, '201611' => '0'
, '201612' => '0'
);
$midlevelExpense = 0;
$midlevelProd = 0;
$midlevelImpact = 0;
$quarterlyTruUpPaid = 0;
while ($midlevelRow = mssql_fetch_array($midlevelQuery)) {
$midlevelExpense = round($midlevelRow['MidlevelProd']);
$midlevelProd = round($midlevelRow['MidlevelProd']);
$midlevelImpact = round($midlevelRow['MidlevelImpact']);
$midlevelQuarterlyImpact = round($midlevelRow['QuarterlyMidlevelImpact']);
$quarterlyTruUpPaid = $midlevelRow['QuarterlyTrueUpUpload'];
$monthlyThreshold = $midlevelRow['MonthlyCFTThreshold'];
$period = $midlevelRow['ReportPeriod'];
$midlevelExpenseArray[$period] = $midlevelExpense;
$midlevelProdArray[$period] = $midlevelProd;
$midlevelImpactArray[$period] = $midlevelImpact;
$midlevelQuarterlyImpactArray[$period] = $midlevelQuarterlyImpact;
$monthlyThresholdArray[$period] += $monthlyThreshold;
if ($quarterlyTruUpPaid > 0) {
$quarterlyTruUpPaidArray[$period] = $quarterlyTruUpPaid;
}
}
// Defaults
$cumulativeExcessEarnedComp = '0';
$currentPeriodArrayKey = array_search($currentPeriod, $periods);
// Actual Work RVUs
$fiscalPeriodWRVUs = array(
'201601' => '0'
, '201602' => '0'
, '201603' => '0'
, '201604' => '0'
, '201605' => '0'
, '201606' => '0'
, '201607' => '0'
, '201608' => '0'
, '201609' => '0'
, '201610' => '0'
, '201611' => '0'
, '201612' => '0'
);
$wrvuCount = 0;
while ($WRVUrow = mssql_fetch_array($query)) {
$actualWRVU = round($WRVUrow['WRVUs_Actual']);
$wrvuCount = $wrvuCount + $actualWRVU;
$period = $WRVUrow['dimDashboardPeriodSK'];
$fiscalPeriodWRVUs[$period] = $actualWRVU;
}
if ($row['CompPlanActive'] > 0) {
$startDate = $row['StartDate'];
} else {
$startDate = '201501';
}
// Actual Work RVUs
$fiscalPeriodWRVUs = array_values($fiscalPeriodWRVUs);
$actualWRVURunningTotal = 0;
$periodCount = 0;
$quarterCount = 1;
$tableRows = '<tr>';
$tableRows .= '<td class="indent">Actual Work RVUs</td>';
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
$WRVUs = $fiscalPeriodWRVUs[$periodCount];
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">' . number_format($WRVUs) . '</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">' . number_format($WRVUs) . '</td>';
}
$actualWRVURunningTotal = $actualWRVURunningTotal + $WRVUs;
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
array_push($quarterly_actualWRVUs, $actualWRVURunningTotal);
$periodCount++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">' . number_format($actualWRVURunningTotal) . '</td>';
$tableRows .= '</tr>';
// Estimated WRVU Base
$monthlyThresholdArray = array_values($monthlyThresholdArray);
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">WRVU Threshold</td>';
$quarterCount = 1;
$periodCount = 0;
$estimatedWRVUBaseTotal = 0;
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
$estimatedWRVUBase = $monthlyThresholdArray[$periodCount];
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">' . number_format($estimatedWRVUBase) . '</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">' . number_format($estimatedWRVUBase) . '</td>';
}
$estimatedWRVUBaseTotal = $estimatedWRVUBaseTotal + $estimatedWRVUBase;
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
$periodCount++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">' . number_format($estimatedWRVUBaseTotal) . '</td>';
$tableRows .= '</tr>';
// Space
$tableRows .= '<tr>';
$tableRows .= '<td colspan="14" class="indent" style="font-weight:bold;text-align:left;">&nbsp;</td>';
$tableRows .= '</tr>';
if ($actualWRVURunningTotal >= $estimatedWRVUBaseTotal) {
$perWRVURate = $row["ThresholdCF"];
} else {
$perWRVURate = $row["DiscountCF"];
}
// Rate per Work RVU
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">Rate per Work RVU</td>';
$periodCount = 0;
$quarterCount = 1;
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
$periodCount++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">$' . number_format($perWRVURate, 2) . '</td>';
$tableRows .= '</tr>';
// Earned Comp
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">Earned Comp</td>';
$earnedCompCounter = 0;
$earnedCompTotal = 0;
$quarterCount = 1;
$earnedCompArray = array();
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
$earnedComp = $fiscalPeriodWRVUs[$earnedCompCounter] * $perWRVURate;
$earnedCompTotal = $earnedCompTotal + $earnedComp;
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
array_push($earnedCompArray, $earnedComp);
array_push($quarterly_earnedComp, $earnedCompTotal);
$earnedCompCounter++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">$' . number_format($earnedCompTotal) . '</td>';
$tableRows .= '</tr>';
// Base Draw
$baseDraw = $baseDrawRow["ClinicalBaseDraw"];
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">Base Draw</td>';
$quarterCount = 1;
$baseDrawTotal = 0;
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
$baseDrawTotal = $baseDraw;
array_push($quarterly_baseDraw, $baseDraw);
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">$' . number_format($baseDrawTotal) . '</td>';
$tableRows .= '</tr>';
// Quality Bonus
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">Quality Bonus Withhold</td>';
$quarterCount = 1;
$qualityBonusTotal = $earnedCompTotal * $row['QualityCompWithholdPercent'];
$excessEarnedCompCounter = 0;
$qualityBonusArray = array();
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
$qualityBonus = $earnedCompArray[$excessEarnedCompCounter] * $row['QualityCompWithholdPercent'];
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
//$qualityBonusTotal = $qualityBonusTotal + $qualityBonus;
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
array_push($qualityBonusArray, $qualityBonus);
$excessEarnedCompCounter++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">$' . number_format($qualityBonusTotal) . '</td>';
$tableRows .= '</tr>';
// Excess Earned Comp
$tableRows .= '<tr style="border-top:2px solid #777;">';
$tableRows .= '<td class="indent">Excess Earned Comp</td>';
$excessEarnedCompCounter = 0;
$qualityBonusCounter = 0;
$excessEarnedCompTotal = 0;
$excessEarnedCompArray = array();
$quarterCount = 1;
$excessEarnedCompTotal = $earnedCompTotal - $baseDrawTotal - $qualityBonusTotal;
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
//$excessEarnedCompTotal = $excessEarnedCompTotal + $excessEarnedComp;
//array_push($excessEarnedCompArray, $excessEarnedComp);
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
$qualityBonusCounter++;
$excessEarnedCompCounter++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">$' . number_format($excessEarnedCompTotal) . '</td>';
$tableRows .= '</tr>';
// Space
$tableRows .= '<tr>';
$tableRows .= '<td colspan="14" class="indent" style="font-weight:bold;text-align:left;">&nbsp;</td>';
$tableRows .= '</tr>';
// Midlevel Productivity
$midlevelProdValues = array_values($midlevelProdArray);
$midlevelProdRunningTotal = 0;
$periodCount = 0;
$quarterCount = 1;
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">Midlevel Productivity</td>';
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
$midlevelProd = $midlevelProdValues[$periodCount];
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
$midlevelProdRunningTotal = $midlevelProdRunningTotal + $midlevelProd;
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
$periodCount++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">' . number_format($midlevelProdRunningTotal) . '</td>';
$tableRows .= '</tr>';
// Midlevel Expense
$midlevelExpenseValues = array_values($midlevelExpenseArray);
$midlevelExpenseRunningTotal = 0;
$periodCount = 0;
$quarterCount = 1;
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">Midlevel Expense</td>';
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
$midlevelExpense = $midlevelExpenseValues[$periodCount];
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
$midlevelExpenseRunningTotal = $midlevelExpenseRunningTotal + $midlevelExpense;
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
$periodCount++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">' . number_format($midlevelExpenseRunningTotal) . '</td>';
$tableRows .= '</tr>';
// Midlevel Impact
$midlevelImpactValues = array_values($midlevelImpactArray);
$midlevelImpactRunningTotal = 0;
$periodCount = 0;
$quarterCount = 1;
$tableRows .= '<tr style="border-top:2px solid #777;">';
$tableRows .= '<td class="indent">Midlevel Impact</td>';
foreach ($periods AS $period) {
if ($period <= $currentPeriod && $period >= $startDate) {
$midlevelImpact = $midlevelImpactValues[$periodCount];
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
$midlevelImpactRunningTotal = $midlevelImpactRunningTotal + $midlevelImpact;
} else {
if ($quarterCount % 3 == 0) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;">-</td>';
}
}
$periodCount++;
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">' . number_format($midlevelImpactRunningTotal) . '</td>';
$tableRows .= '</tr>';
// Space
$tableRows .= '<tr>';
$tableRows .= '<td colspan="14" class="indent" style="font-weight:bold;text-align:left;">&nbsp;</td>';
$tableRows .= '</tr>';
// Space
$tableRows .= '<tr>';
$tableRows .= '<td colspan="14" class="indent" style="font-weight:bold;text-align:left;">&nbsp;</td>';
$tableRows .= '</tr>';
// Quarterly - Quarterly True Ups Paid
$tableRows .= '<tr>';
$tableRows .= '<td class="indent">Quarterly True Ups Paid</td>';
$quarterCount = 1;
$periodCount = 0;
$quarterlyTruUpPaidTotal = 0;
$quarterlyTruUpPaidValues = array_values($quarterlyTruUpPaidArray);
//error_log(serialize($quarterlyTruUpPaidArray), 1, 'gortiz@equationhealth.com');
foreach ($periods AS $period) {
$quarterlyTruUpPaid = $quarterlyTruUpPaidValues[$periodCount];
$quarterlyTruUpPaidTotal = $quarterlyTruUpPaidTotal + $quarterlyTruUpPaid;
if ($quarterCount % 3 == 0) {
if ($quarterCount == 3 && ($currentPeriodArrayKey <= 2 || $currentPeriodArrayKey > 2) && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">$' . number_format($quarterlyTruUpPaid) . '</td>';
} elseif ($quarterCount == 6 && $currentPeriodArrayKey >= 5 && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">$' . number_format($quarterlyTruUpPaid) . '</td>';
} elseif ($quarterCount == 9 && $currentPeriodArrayKey >= 8 && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">$' . number_format($quarterlyTruUpPaid) . '</td>';
} elseif ($quarterCount == 12 && $currentPeriodArrayKey >= 11 && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">$' . number_format($quarterlyTruUpPaid) . '</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;background-color:#f8f8f8;">-</td>';
}
} else {
$tableRows .= '<td class="full"></td>';
}
$quarterCount++;
$periodCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">$' . number_format($quarterlyTruUpPaidTotal) . '</td>';
$tableRows .= '</tr>';
// Quarterly - Adjusted Excess Earned Comp
$tableRows .= '<tr style="border-top:2px solid #777;">';
$tableRows .= '<td class="indent">Estimated Earned Comp Due</td>';
$quarterCount = 1;
$earnedCompDue = $excessEarnedCompTotal + $midlevelImpactRunningTotal - $quarterlyTruUpPaidTotal;
foreach ($periods AS $period) {
if ($quarterCount % 3 == 0) {
if ($quarterCount == 3 && ($currentPeriodArrayKey <= 2 || $currentPeriodArrayKey > 2) && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;border-bottom:1px solid #eee;background-color:#f8f8f8;">-</td>';
} elseif ($quarterCount == 6 && $currentPeriodArrayKey >= 5 && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;border-bottom:1px solid #eee;background-color:#f8f8f8;">-</td>';
} elseif ($quarterCount == 9 && $currentPeriodArrayKey >= 8 && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;border-bottom:1px solid #eee;background-color:#f8f8f8;">-</td>';
} elseif ($quarterCount == 12 && $currentPeriodArrayKey >= 11 && $period >= $startDate) {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;border-bottom:1px solid #eee;background-color:#f8f8f8;">-</td>';
} else {
$tableRows .= '<td class="full" style="text-align:right;border-right:1px solid #eee;border-left:1px solid #eee;border-bottom:1px solid #eee;background-color:#f8f8f8;">-</td>';
}
} else {
$tableRows .= '<td class="full"></td>';
}
$quarterCount++;
}
$tableRows .= '<td class="border-right" style="text-align:right;">$' . number_format($earnedCompDue) . '</td>';
$tableRows .= '</tr>';
return array(
'tableDisplay' => $tableRows,
'tableDisplayHeader' => $tableHeaders
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment