Ejemplo n.º 1
0
 function display($tpl = null)
 {
     // get combined params of both component and menu
     $this->app = JFactory::getApplication();
     $this->params = $this->app->getParams();
     $this->menu = $this->app->getMenu()->getActive();
     // get the user object
     $this->user = JFactory::getUser();
     // Initialise variables.
     $this->item = $this->get('Item');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // check if the data was returned
     if ($this->item) {
         // get results
         $data = base64_encode(serialize($this->item));
         $this->results = CostbenefitprojectionHelper::calculate($this->item->id, $data);
     } else {
         // int all as false
         $this->results = false;
     }
     // Set the toolbar
     $this->addToolBar();
     // set the document
     $this->_prepareDocument();
     parent::display($tpl);
 }
Ejemplo n.º 2
0
 protected function setCompaniesInfo(&$items)
 {
     if (CostbenefitprojectionHelper::checkArray($items)) {
         // we must check the currency
         $currency = array('currency_id', 'currency_name', 'currency_codethree', 'currency_numericcode', 'currency_symbol', 'currency_thousands', 'currency_decimalplace', 'currency_decimalsymbol', 'currency_positivestyle', 'currency_negativestyle');
         $names = array();
         $namesnot = array();
         foreach ($items as $nr => &$item) {
             if (!isset($this->currencyDetails->currency_id)) {
                 $this->currencyDetails = new stdClass();
                 foreach ($currency as $key) {
                     $this->currencyDetails->{$key} = $item->{$key};
                 }
             } elseif ($item->currency_id !== $this->currencyDetails->currency_id) {
                 $namesnot[] = $item->name;
                 continue;
             }
             $data = base64_encode(serialize($item));
             $this->datasets[] = CostbenefitprojectionHelper::calculate($item->id, $data);
             // set some defaults
             $names[] = $item->name;
         }
         if (CostbenefitprojectionHelper::checkArray($namesnot)) {
             $companiesNamesNot = '<b>' . implode(', ', $namesnot) . '</b>';
             JError::raiseWarning(500, JText::_('Currency mismatch! These were excluded from results: ') . $companiesNamesNot);
         }
         if (CostbenefitprojectionHelper::checkArray($names)) {
             $this->companiesNames = implode(', ', $names);
             return true;
         }
     }
 }
Ejemplo n.º 3
0
 function display($tpl = null)
 {
     // get component params
     $this->params = JComponentHelper::getParams('com_costbenefitprojection');
     // get the application
     $this->app = JFactory::getApplication();
     // get the user object
     $this->user = JFactory::getUser();
     // get global action permissions
     $this->canDo = CostbenefitprojectionHelper::getActions('companyresults');
     // Initialise variables.
     $this->item = $this->get('Item');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     // check if the data was returned
     if ($this->item) {
         // get results
         $data = base64_encode(serialize($this->item));
         $this->results = CostbenefitprojectionHelper::calculate($this->item->id, $data);
         // set the tab details
         $this->chart_tabs = $this->getChartTabs();
         $this->table_tabs = $this->getTableTabs();
     } else {
         // int all as false
         $this->results = false;
         // set the tab details
         $this->chart_tabs = false;
         $this->table_tabs = false;
     }
     // We don't need toolbar in the modal window.
     if ($this->getLayout() !== 'modal') {
         // add the tool bar
         $this->addToolBar();
     }
     // set the document
     $this->setDocument();
     parent::display($tpl);
 }
Ejemplo n.º 4
0
 public function getCalculatedResult($id, $data)
 {
     return CostbenefitprojectionHelper::calculate($id, $data);
 }