public function getChartData() { $id = $_GET['optId']; $opptProducts = OpportunityProduct::getAllByOpptId(intval($id)); $count = count($opptProducts); $totalDirectCost = 0; $totalMH = 0; $suggestedPrice = 0; $opptPdctMap; $categoryValues = array(); $totalCostValues = array(); if (count($opptProducts) > 0) { foreach ($opptProducts as $row) { $opptPdctMap[$row->Category][] = $row; } foreach ($opptPdctMap as $key => $optpdctArray) { foreach ($optpdctArray as $optKey => $optpdt) { $categoryValues[] = $key; $totalCostValues[] = $optpdt->Total_Direct_Cost->value; $chartArr = array_combine($categoryValues, $totalCostValues); $totalDirectCost += $optpdt->Total_Direct_Cost->value; $suggestedPrice += $optpdt->Final_Cost->value; $totalMH += $optpdt->Total_MHR; } } $newChartArr = $this->array_combine_($categoryValues, $totalCostValues); foreach ($newChartArr as $k => $v) { if (is_array($newChartArr[$k])) { $newChartArr[$k] = array_sum($newChartArr[$k]); } else { $newChartArr[$k] = $newChartArr[$k]; } } } $arr_keys = array_keys($newChartArr); $arr_values = array_values($newChartArr); $chartData = array(); for ($i = 0; $i < count($newChartArr); $i++) { $chartData[$i]['value'] = $arr_values[$i]; $chartData[$i]['displayLabel'] = $arr_keys[$i]; } return $chartData; }
public function getChartData() { $id = $_GET['optId']; $optPrdcts = OpportunityProduct::getAllByOpptId(intval($id)); $count = count($optPrdcts); $totalDirectCost = 0.0; $tBurdenCost = 0.0; $tLaborCost = 0.0; $tEquipmentCost = 0.0; $tMaterialCost = 0.0; $tSubCost = 0.0; $tOtherCost = 0.0; foreach ($optPrdcts as $optPrdct) { $tLaborCost += $optPrdct->Labor_Cost->value; $totalDirectCost += $optPrdct->Total_Direct_Cost->value; $tBurdenCost += $optPrdct->Burden_Cost->value; $tEquipmentCost += $optPrdct->Equipment_Cost->value; $tMaterialCost += $optPrdct->Materials_Cost->value; $tSubCost += $optPrdct->Sub_Cost->value; $tOtherCost += $optPrdct->Other_Cost->value; } $chartData = array(); if ($tLaborCost != 0.0 && $tLaborCost != 0) { $chartData[] = array('value' => $utf8_text = $this->resolveCurrencyValueConversionRateForCurrentUserForDisplay($tLaborCost), 'displayLabel' => 'Labor Cost'); } if ($tBurdenCost != 0.0 && $tBurdenCost != 0) { $chartData[] = array('value' => $utf8_text = $this->resolveCurrencyValueConversionRateForCurrentUserForDisplay($tBurdenCost), 'displayLabel' => 'Burden Cost'); } if ($tEquipmentCost != 0.0 && $tEquipmentCost != 0) { $chartData[] = array('value' => $utf8_text = $this->resolveCurrencyValueConversionRateForCurrentUserForDisplay($tEquipmentCost), 'displayLabel' => 'Equipment Cost'); } if ($tMaterialCost != 0.0 && $tMaterialCost != 0) { $chartData[] = array('value' => $utf8_text = $this->resolveCurrencyValueConversionRateForCurrentUserForDisplay($tMaterialCost), 'displayLabel' => 'Material Cost'); } if ($tSubCost != 0.0 && $tSubCost != 0) { $chartData[] = array('value' => $utf8_text = $this->resolveCurrencyValueConversionRateForCurrentUserForDisplay($tSubCost), 'displayLabel' => 'Subcontractor Cost'); } if ($tOtherCost != 0.0 && $tOtherCost != 0) { $chartData[] = array('value' => $utf8_text = $this->resolveCurrencyValueConversionRateForCurrentUserForDisplay($tOtherCost), 'displayLabel' => 'Other Cost'); } return $chartData; }
public function makeOpportunityProductSelection($datas, $opportunityId) { $content = ''; $opptProducts = OpportunityProduct::getAllByOpptId(intval($opportunityId)); $opportunity = Opportunity::getById($opportunityId); $count = count($opptProducts); $totalDirectCost = 0; $totalMH = 0; $suggestedPrice = 0; $opptPdctMap; if (count($opptProducts) > 0) { foreach ($opptProducts as $row) { $opptPdctMap[$row->Category][] = $row; } $tableCreation = ''; $tableCreation .= '<div class="view-toolbar-container clearfix"> <div style="background-color:#E0D1D1; color:black;padding:0.5%; font-weight:bold; font-size: 13px;"> Estimate Summary </div> <div style="font-weight: bold; padding: 10px;">Number Of Products :' . $count . '</div>'; $tableCreation .= '<table border="1" width="100%" class="items"> <colgroup span="5"></colgroup>'; $tableCreation .= '<thead style="font-weight: bold; background-color:#E6E6E6; color: black;padding: 5px;"> <tr style="border: 1px solid gray;"> <th colspan="13" style="font-weight: bold;padding: 10px;text-align:center;">Opportunity Products</th> </tr> <th style="font-weight: bold;padding: 10px;text-align:center;">Product Code</th> <th style="font-weight: bold;padding: 10px;text-align:center;">Product Name</th> <th style="font-weight: bold;padding: 10px;text-align:center;">Unit of Measure</th> <th style="font-weight: bold;padding: 10px;text-align:center;">Quantity</th> <th style="font-weight: bold;padding: 10px;text-align:center;">Frequency</th> <th style="font-weight: bold;padding: 10px;text-align:center;">MH</th> <th style="font-weight: bold;padding: 10px;text-align:center;">L</th> <th style="font-weight: bold;padding: 10px;text-align:center;">B</th> <th style="font-weight: bold;padding: 10px;text-align:center;">M</th> <th style="font-weight: bold;padding: 10px;text-align:center;">E</th> <th style="font-weight: bold;padding: 10px;text-align:center;">S</th> <th style="font-weight: bold;padding: 10px;text-align:center;">O</th> <th style="font-weight: bold;padding-top: 10px;text-align:center;">Total Direct Cost</th> </thead><tbody>'; foreach ($opptPdctMap as $key => $optpdctArray) { $tableCreation .= '<th style="padding: 3px;font-weight: bold;background-color:gray;color:white;" colspan="13">' . $key . '</th>'; foreach ($optpdctArray as $optKey => $optpdt) { $totalDirectCost += $optpdt->Total_Direct_Cost->value; $suggestedPrice += $optpdt->Final_Cost->value; $totalMH += $optpdt->Total_MHR; $tableCreation .= '<tr> <td style="width: 8%; text-align: left; padding: 3px;">' . $optpdt->costbook->productcode . '</td> <td style="width: 15%; text-align: left; padding: 3px;">' . $optpdt->name . '</td> <td style="width: 4%; text-align: center; padding: 3px;">' . $optpdt->costbook->unitofmeasure . '</td> <td style="width: 5%; text-align: center; padding: 3px">' . $optpdt->Quantity . '</td> <td style="width: 5%; text-align: center; padding: 3px">' . $optpdt->Frequency . '</td> <td style="width: 6%; text-align: center; padding: 3px">' . $optpdt->Total_MHR . '</td> <td style="width: 6%;padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Labor_Cost . '</td> <td style="width: 6%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Burden_Cost . '</td> <td style="width: 6%;padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Materials_Cost . '</td> <td style="width: 6%;padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Equipment_Cost . '</td> <td style="width: 6%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Sub_Cost . '</td> <td style="width: 6%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Other_Cost . '</td> <td style="width: 16%; padding-top: 2px; text-align: right; padding: 3px">' . OpportunityProductUtils::getCurrencyType() . $optpdt->Total_Direct_Cost->value . '</td> </tr>'; } } $tableCreation .= '</tbody></table>'; $tableCreation .= '<table style="margin-left: 20%; margin-top:2%;" border="0" cellpadding="2" width="60%" text-align="right"> <tr> <td rowspan="2" style="text-align:center; font-weight: bold;color:black;">Direct Cost</td> <td style="text-align:right; font-weight: bold;color:black;">Total</td> <td style="text-align:right;"></td> <td style="text-align:right; font-weight: bold;color:black;">Suggested</td> <td style="text-align:right; font-weight: bold;color:black;">Final</td> </tr> <tr> <td style="text-align:right; color:black;">' . OpportunityProductUtils::getCurrencyType() . number_format($totalDirectCost, 2) . '</td> <td style="text-align:right; font-weight: bold;color:black;">Price</td> <td style="text-align:right; color:green;">' . OpportunityProductUtils::getCurrencyType() . number_format($suggestedPrice, 2) . '</td> <td style="text-align:right; color:green;">' . OpportunityProductUtils::getCurrencyType() . number_format($opportunity->amount->value, 2) . '</td> </tr> <tr> <td style="text-align:center; font-weight: bold;color:black;">MH</td> <td style="text-align:right; color:black;">' . $totalMH . '</td> <td style="text-align:right; font-weight: bold;color:black;">Rev/MH</td> <td style="text-align:right; color:black;">' . OpportunityProductUtils::getCurrencyType() . number_format($suggestedPrice / $totalMH, 2) . '</td> <td style="text-align:right;">' . OpportunityProductUtils::getCurrencyType() . number_format($opportunity->amount->value / $totalMH, 2) . '</td> </tr> <tr> <td colspan="2" style="text-align:right;"></td> <td style="text-align:right; font-weight: bold;color:black;">Aggregate GPM%</td> <td style="text-align:right; color:black;">' . number_format(($suggestedPrice - $totalDirectCost) / $suggestedPrice * 100, 2) . ' </td> <td style="text-align:right; color:black;">' . number_format(($opportunity->amount->value - $totalDirectCost) / $opportunity->amount->value * 100, 2) . '</td> </tr> </table>'; $tableCreation .= '</div><br/><br/><div style="background-color:#E0D1D1; color:black;padding:0.5%; margin-bottom:1%; font-weight:bold; font-size: 13px;">Charts</div>'; -($tableCreation .= OpportunityProductUtils::estimatorSummaryPiechartView($opportunityId)); -($tableCreation .= '<hr>'); $tableCreation .= '</div>'; $content .= $tableCreation; } $content .= '</tbody></table> <input value="" name="list-view-selectedIds" id="list-view-selectedIds" type="hidden"> </div>'; return $content; }