Ejemplo n.º 1
0
 /**
  * Create widget on object creation 
  **/
 public function __construct($context)
 {
     parent::__construct($context);
     //**********************************START OF VAR INIT**********************************************
     $validator = new Validation();
     $calculations = new Calculations();
     //current, increase and new order values
     $CorderVal = $validator->calcInputCheck('CorderVal');
     $IorderVal = $validator->calcInputCheck('IorderVal');
     $NorderVal = $calculations->increasebyPercentage($CorderVal, $IorderVal);
     //current, increase and new visitors per month
     $CvisitorsPerMonth = $validator->calcInputCheck('CvisitorsPerMonth');
     $IvisitorsPerMonth = $validator->calcInputCheck('IvisitorsPerMonth');
     $NvisitorsPerMonth = $calculations->increasebyPercentage($CvisitorsPerMonth, $IvisitorsPerMonth);
     //current, increase and new conversion rate
     $CconversionRate = $validator->calcInputCheck('CconversionRate');
     $IconversionRate = $validator->calcInputCheck('IconversionRate');
     $NconversionRate = $calculations->increasebyPercentage($CconversionRate, $IconversionRate);
     //current, Increase and new Av Margins
     $CavMargin = $validator->calcInputCheck('CavMargin');
     $IavMargin = $validator->calcInputCheck('IavMargin');
     $NavMargin = $calculations->increaseByPercentage($CavMargin, $IavMargin);
     //current, increase and new revenue values
     $Crevenue = $calculations->computeRevenue($CorderVal, $CvisitorsPerMonth, $CconversionRate);
     $Nrevenue = $calculations->computeRevenue($NorderVal, $NvisitorsPerMonth, $NconversionRate);
     $Irevenue = $calculations->computePercentageIncrease($Crevenue, $Nrevenue);
     //current, increase and new Gross Profit Margin
     $Cgpm = $calculations->computeGrossProfitMargin($Crevenue, $CavMargin);
     $Ngpm = $calculations->computeGrossProfitMargin($Nrevenue, $NavMargin);
     $Igpm = $calculations->computePercentageIncrease($Cgpm, $Ngpm);
     //Investement capital and ROI
     $investement = $validator->calcInputCheck('investement');
     $roi = $calculations->computeROI($investement, $Ngpm, $Cgpm);
     //*********************************ENDOF VAR INIT**************************************************
     //*********************************START OF HTML***************************************************
     //initialise rows for calculator table
     $row1 = $this->headerRow("Current Value", "Percentage Increase", "New Value");
     $row2 = $this->calculationRow("Av Order Value", $CorderVal, $IorderVal, "CorderVal", "IorderVal", $NorderVal);
     $row3 = $this->calculationRow("Visitors Per Month", $CvisitorsPerMonth, $IvisitorsPerMonth, "CvisitorsPerMonth", "IvisitorsPerMonth", $NvisitorsPerMonth);
     $row4 = $this->calculationRow("Conversion Rate", $CconversionRate, $IconversionRate, "CconversionRate", "IconversionRate", $NconversionRate);
     $row5 = $this->calculationRow("Av Margin", $CavMargin, $IavMargin, "CavMargin", "IavMargin", $NavMargin);
     $row6 = $this->resultsRow("Revenue", $Crevenue, $Irevenue, $Nrevenue);
     $row7 = $this->resultsRow("Gross Profit Margin", $Cgpm, $Igpm, $Ngpm);
     $row8 = $this->investROIrow("Investement", "ROI", $investement, "investement", $roi);
     //create table from above rows,
     $calcTable = HTML_Gen::element("TABLE", "class='table table-bordered'", $row1 . $row2 . $row3 . $row4 . $row5 . $row6 . $row7 . $row8);
     $submitBtn = HTML_Gen::element("INPUT", "type='submit' value='submit'", "");
     $calcForm = HTML_Gen::element("FORM", "action='{$context}' method='POST'", $calcTable . $submitBtn);
     echo $calcContainer = HTML_Gen::element("DIV", "class='form-group'", $calcForm);
     //*******************************ENDOF HTML*******************************************************
 }