public function renderContent() { $content = OpportunityProductUtils::makeCostBookProductSelection($this->data, $this->opportunityId); // $content = 'Test'; $content .= $this->renderScripts(); return $content; }
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; }
public function renderContent() { $content = OpportunityProductUtils::makeCostBookProductSelection($this->data, $this->opportunityId); return $content; }
public function actionUpdateOpportunityProducts($jsonObj, $optId) { $datas = json_decode($jsonObj, true); if ($datas != null) { foreach ($datas as $Data) { $optpdct = OpportunityProduct::getById($Data['product_ids']); if (OpportunityProductUtils::updateOpportunityProduct($optpdct, $Data['Quantity'], $Data['Frequency']) == false) { break; } } echo json_encode("Values Updated"); } }