function display()
 {
     global $app_list_strings, $mod_strings, $current_language, $current_user, $dictionary;
     if ($GLOBALS['sugar_config']['KReports']['trace']) {
         global $db;
         $db->query("INSERT INTO kreportstats SET id='" . create_guid() . "', user_id='{$current_user->id}', report_id='" . $this->bean->id . "', date=now()");
     }
     // build the langiage strings
     $mod_lang = return_module_language($current_language, 'KReports');
     foreach ($mod_lang as $id => $value) {
         $returnArray[] = array('lblid' => $id, 'value' => $value);
     }
     // maretval: get parent Report information
     if (isset($_REQUEST['parentreportid']) && !empty($_REQUEST['parentreportid'])) {
         $parentReport = new KReport();
         $parentReport->retrieve($_REQUEST['parentreportid']);
         $parentReport_whereconditions = json_decode(html_entity_decode($parentReport->whereconditions));
     }
     // dynamic Select Options
     if (isset($_REQUEST['dynamicoptions'])) {
         $whereFieldsList = json_decode_kinamu(html_entity_decode($this->bean->whereconditions, ENT_QUOTES));
         $loadParams = json_decode(html_entity_decode(base64_decode($_REQUEST['dynamicoptions'])), true);
         foreach ($loadParams as $loadParam) {
             foreach ($whereFieldsList as $fieldIndex => $fieldData) {
                 if ($fieldData['usereditable'] != 'no' && (!empty($loadParam['reference']) && $loadParam['reference'] == $fieldData['reference'] || !empty($loadParam['fieldid']) && $loadParam['fieldid'] == $fieldData['fieldid'])) {
                     if (!empty($loadParam['operator'])) {
                         $whereFieldsList[$fieldIndex]['operator'] = $loadParam['operator'];
                     }
                     if (!empty($loadParam['value'])) {
                         $whereFieldsList[$fieldIndex]['value'] = $loadParam['value'];
                     }
                     if (!empty($loadParam['valuekey'])) {
                         $whereFieldsList[$fieldIndex]['valuekey'] = $loadParam['valuekey'];
                     }
                     if (!empty($loadParam['valueto'])) {
                         $whereFieldsList[$fieldIndex]['valueto'] = $loadParam['valueto'];
                     }
                     if (!empty($loadParam['valuetokey'])) {
                         $whereFieldsList[$fieldIndex]['valuetokey'] = $loadParam['valuetokey'];
                     }
                 }
             }
         }
         $this->bean->whereconditions = json_encode($whereFieldsList);
     }
     $editableWhereFields = $this->bean->get_runtime_wherefilters();
     $jsonWhereOptions = str_replace("\"", "'", json_encode_kinamu($editableWhereFields));
     if (count($editableWhereFields) > 0) {
         $this->ss->assign('dynamicoptions', $jsonWhereOptions);
     } else {
         $this->ss->assign('dynamicoptions', '');
     }
     // set the language Parameters
     $this->ss->assign('jsonlanguage', json_encode_kinamu($returnArray));
     // view Specifics
     //if ($this->bean->listtype != 'standard' & $this->bean->listtype != '') {
     $pluginManager = new KReportPluginManager();
     $thisPresentationManager = new KReportPresentationManager();
     $this->ss->assign('presentation', JSMin::minify($thisPresentationManager->renderPresentation($this->bean)));
     // get the Integration PPlugins
     $this->ss->assign('integrationpluginjs', JSMin::minify($pluginManager->getIntegrationPlugins($this->bean)));
     $thisVisualizationManager = new KReportVisualizationManager();
     //$this->ss->assign('visualization', JSMin::minify($thisVisualizationManager->renderVisualization(html_entity_decode($this->bean->visualization_params, ENT_QUOTES, 'UTF-8'), $this->bean)));
     $this->ss->assign('visualization', $thisVisualizationManager->renderVisualization(html_entity_decode($this->bean->visualization_params, ENT_QUOTES, 'UTF-8'), $this->bean));
     // set the view js
     //if ($this->bean->listtype == '')
     //    $this->bean->listtype = 'standard';
     //$this->ss->assign('viewJS', $this->setFormatVars() . '<script type="text/javascript" src="modules/KReports/views/view.detail.' . $this->bean->listtype . /* @ObfsProperty@ */ '.js" charset="utf-8"></script>');
     // override the options settings if the user is the admin
     $optionsJson = json_decode(html_entity_decode($this->bean->reportoptions));
     if ($current_user->is_admin) {
         $optionsJson->showTools = true;
         $optionsJson->showExport = true;
         $optionsJson->showSnapshots = true;
     }
     $this->ss->assign('reportoptions', json_encode($optionsJson));
     // build js variables
     require_once 'modules/ACL/ACLController.php';
     $jsVariables = '';
     //edit & delete
     // if (ACLController::checkAccess($this->bean->module_dir, 'edit', $this->bean->assigned_user_id == $current_user->id ? true : false)) {
     if ($this->bean->ACLAccess('edit')) {
         //if (ACLController::checkAccess($this->bean->module_dir, 'delete', $this->bean->assigned_user_id == $current_user->id ? true : false))
         if ($this->bean->ACLAccess('delete')) {
             $jsVariables .= "var accessLevel= 2;";
         } else {
             $jsVariables .= "var accessLevel= 1;";
         }
     } else {
         $jsVariables .= "var accessLevel= 0;";
     }
     // set the record id
     $jsVariables .= "var reportId='" . $this->bean->id . "';";
     // set if the Reporter is in DebugMode
     if ($GLOBALS['sugar_config']['KReports']['debug']) {
         $jsVariables .= "var kreportDebug=true;";
         $this->ss->assign('kreportDebug', true);
     } else {
         $jsVariables .= "var kreportDebug=false;";
         $this->ss->assign('kreportDebug', false);
     }
     // get all the where editable fields per operator
     include 'modules/KReports/config/KReportWhereOperators.php';
     $jsVariables .= "var kreportoperatorcount=" . json_encode($kreporterWhereOperatorCount) . ";";
     // add general format vars
     $jsVariables .= $this->setFormatVars();
     // 2013-03-18 add a config param for the Ext.AJAX timeout Bug #446
     if (!empty($GLOBALS['sugar_config']['KReports']['AJAXTimeout'])) {
         $jsVariables .= "Ext.Ajax.timeout = " . $GLOBALS['sugar_config']['KReports']['AJAXTimeout'] . ";";
     }
     $this->ss->assign('jsVariables', JSMin::minify($jsVariables));
     // process the view
     parent::display();
 }
 public function action_pluginaction()
 {
     $pluginManager = new KReportPluginManager();
     return $pluginManager->processPluginAction($_REQUEST['plugin'], 'action_' . $_REQUEST['pluginaction'], $this);
 }
 function display()
 {
     global $app_list_strings, $mod_strings, $current_language, $dictionary, $sugar_config;
     // ann Add Js Strinf that will be assigned at the end befor ehte view gets rendered
     $this->addJsString = '';
     $jsVariables = '';
     // get the Sugar Flavor
     $jsVariables .= "var sugar_flavor='" . $GLOBALS['sugar_flavor'] . "';";
     // get all the where editable fields per operator
     include 'modules/KReports/config/KReportWhereOperators.php';
     $jsVariables .= "var kreportoperatorcount=" . json_encode($kreporterWhereOperatorCount) . ";";
     $mod_lang = return_module_language($current_language, 'KReports');
     foreach ($mod_lang as $id => $value) {
         $returnArray[] = array('lblid' => $id, 'value' => $value);
     }
     // add the app list array we need
     if (is_array($this->bean->field_defs) && count($this->bean->field_defs) > 0) {
         foreach ($this->bean->field_defs as $fieldId => $fieldDetails) {
             if (isset($fieldDetails['options']) && isset($app_list_strings[$fieldDetails['options']])) {
                 $thisString = jarray_encode_kinamu($app_list_strings[$fieldDetails['options']]);
                 $returnArray[] = array('lblid' => $fieldId . '_options', 'value' => jarray_encode_kinamu($app_list_strings[$fieldDetails['options']]));
             }
         }
     }
     // set the language
     $langJson = json_encode_kinamu($returnArray);
     $this->ss->assign('jsonlanguage', json_encode_kinamu($returnArray));
     // see if we have a return id
     if (!isset($_REQUEST['return_id']) || $_REQUEST['return_id'] == '') {
         $_REQUEST['return_id'] = $this->bean->id;
     }
     // set Options
     if ($this->bean->reportoptions == '') {
         $this->bean->reportoptions = '{"resultsFolded":false,"optionsFolded":true,"authCheck":"full","showDeleted":false,"showExport":true,"showSnapshots":false,"showTools":true}';
     }
     // handle Plugins
     $pluginManager = new KReportPluginManager();
     $pluginManager->getEditViewPlugins($this);
     // handle authorization objects
     if (!empty($GLOBALS['KAuthAccessController'])) {
         if ($GLOBALS['KAuthAccessController']->orgManaged('KReport')) {
             $jsVariables .= "var korgmanaged=true;";
         } else {
             $jsVariables .= "var korgmanaged=false;";
         }
     }
     // manage Visualitazion Variables
     $thisVisualizationManager = new KReportVisualizationManager();
     $this->addJsString .= $thisVisualizationManager->getLayouts();
     // assign to the Template
     $this->ss->assign('editViewAddJs', $this->addJsString);
     //2013-03-15 pass in teh auth check type
     $jsVariables .= 'kreportAuthCheck=\'' . $sugar_config['KReports']['authCheck'] . '\';';
     // handle access authentication for Dialog
     global $sugar_config;
     switch ($sugar_config['KReports']['authCheck']) {
         case 'KAuthObjects':
             $this->ss->assign('authaccess_id', $this->bean->korgobjectmain);
             // get the name
             require_once 'modules/KOrgObjects/KOrgObject.php';
             $thisObject = new KOrgObject();
             $thisObject->retrieve($this->bean->korgobjectmain);
             $this->ss->assign('authaccess_name', $thisObject->name);
             break;
         case 'SecurityGroups':
             $thisRecord = $db->fetchByAssoc($db->query("SELECT securitygroups_records.id, name FROM securitygroups_records INNER JOIN securitygroups ON securitygroups.id = securitygroups_records.securitygroup_id WHERE securitygroups_records.record_id='" . $this->bean->id . "'"));
             if ($thisRecord) {
                 $this->ss->assign('authaccess_id', $thisRecord['id']);
                 $this->ss->assign('authaccess_name', $thisRecord['name']);
             }
             break;
         case 'PRO':
             if (!empty($this->bean->team_id)) {
                 $thisTeam = BeanFactory::getBean('Teams', $this->bean->team_id);
                 $this->ss->assign('team_name', $thisTeam->name . ' ' . $thisTeam->name_2);
             }
             break;
     }
     // set ambigious ariables
     $this->ss->assign('jsVariables', $jsVariables);
     // set if the Reporter is in DebugMode
     if ($GLOBALS['sugar_config']['KReports']['debug']) {
         $jsVariables .= "var kreportDebug=true;";
         $this->ss->assign('kreportDebug', true);
     } else {
         $jsVariables .= "var kreportDebug=false;";
         $this->ss->assign('kreportDebug', false);
     }
     if (!empty($this->bean->team_id)) {
         $thisTeam = BeanFactory::getBean('Teams', $this->bean->team_id);
         $this->ss->assign('team_name', $thisTeam->name . ' ' . $thisTeam->name_2);
     }
     // off we go
     parent::display();
 }