コード例 #1
0
 public function action_export_to_targetlist()
 {
     $thisReport = new KReport();
     $thisReport->retrieve($_REQUEST['record']);
     // check if we have set dynamic Options
     if (isset($_REQUEST['whereConditions'])) {
         $thisReport->whereOverride = json_decode_kinamu(html_entity_decode($_REQUEST['whereConditions']));
     }
     $thisReport->createTargeList($_REQUEST['targetlist_name']);
     return true;
 }
コード例 #2
0
 function action_save_standard_layout()
 {
     $thisReport = new KReport();
     $thisReport->retrieve($_REQUEST['record']);
     $layoutParams = json_decode_kinamu(html_entity_decode($_REQUEST['layoutparams']));
     $listFields = json_decode_kinamu(html_entity_decode($thisReport->listfields));
     // process the Fields
     foreach ($listFields as $thisFieldIndex => $thisListField) {
         reset($layoutParams);
         foreach ($layoutParams as $thisLayoutParam) {
             if ($thisLayoutParam['dataIndex'] == $thisListField['fieldid']) {
                 $thisListField['width'] = $thisLayoutParam['width'];
                 $thisListField['sequence'] = (string) $thisLayoutParam['sequence'];
                 // bug 2011-03-04 sequence needs leading 0
                 if (strlen($thisListField['sequence']) < 2) {
                     $thisListField['sequence'] = '0' . $thisListField['sequence'];
                 }
                 $thisListField['display'] = $thisLayoutParam['isHidden'] ? 'no' : 'yes';
                 $listFields[$thisFieldIndex] = $thisListField;
                 break;
             }
         }
     }
     usort($listFields, 'arraySortBySequence');
     $thisReport->listfields = json_encode_kinamu($listFields);
     echo $thisReport->save();
     echo $thisReport->listfields;
 }
コード例 #3
0
 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();
 }
コード例 #4
0
ファイル: KReport.php プロジェクト: shoaib-fazal16/dumpster
 function get_runtime_wherefilters()
 {
     // return Array
     $editableWhereFields = array();
     // get the Where Fields
     $whereFieldsList = json_decode_kinamu(html_entity_decode($this->whereconditions, ENT_QUOTES));
     // loop over the Fields
     foreach ($whereFieldsList as $whereFieldKey => $whereField) {
         if ($whereField['usereditable'] != 'no') {
             // 2011-03-10 for values where pe parse for the editview differently
             // special handling for specific types
             switch ($whereField['operator']) {
                 case 'lastnddays':
                     switch ($whereField['type']) {
                         case 'datetimecombo':
                         case 'datetime':
                             $origValue = $whereField['value'];
                             $whereField['value'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() - $origValue * 86400) . ' 00:00:00';
                             $whereField['valuekey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() - $origValue * 86400) . ' 00:00:00';
                             break;
                         default:
                             $origValue = $whereField['value'];
                             $whereField['value'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() - $origValue * 86400);
                             $whereField['valuekey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() - $origValue * 86400);
                             break;
                     }
                     break;
                 case 'nextnddays':
                     switch ($whereField['type']) {
                         case 'datetimecombo':
                         case 'datetime':
                             $origValue = $whereField['value'];
                             $whereField['value'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() + $origValue * 86400) . ' 00:00:00';
                             $whereField['valuekey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() + $origValue * 86400) . ' 00:00:00';
                             break;
                         default:
                             $origValue = $whereField['value'];
                             $whereField['value'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() + $origValue * 86400);
                             $whereField['valuekey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() + $origValue * 86400);
                             break;
                     }
                     break;
                 case 'betwnddays':
                     switch ($whereField['type']) {
                         case 'datetimecombo':
                         case 'datetime':
                             $origValue = $whereField['value'];
                             $origValueto = $whereField['valueto'];
                             $whereField['value'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() + $origValue * 86400) . ' 00:00:00';
                             $whereField['valuekey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() + $origValue * 86400) . ' 00:00:00';
                             $whereField['valueto'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() + $origValueto * 86400) . ' 00:00:00';
                             $whereField['valuetokey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() + $origValueto * 86400) . ' 00:00:00';
                             break;
                         default:
                             $origValue = $whereField['value'];
                             $origValueto = $whereField['valueto'];
                             $whereField['value'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() + $origValue * 86400);
                             $whereField['valuekey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() + $origValue * 86400);
                             $whereField['valueto'] = date($GLOBALS['timedate']->get_date_format(), gmmktime() + $origValueto * 86400);
                             $whereField['valuetokey'] = date($GLOBALS['timedate']->get_db_date_format(), gmmktime() + $origValueto * 86400);
                             break;
                     }
                     break;
                 case 'lastndays':
                 case 'lastnfdays':
                 case 'lastnweeks':
                 case 'lastnfmonth':
                 case 'lastnfweeks':
                 case 'nextndays':
                 case 'nextnweeks':
                 case 'betwndays':
                     break;
                 default:
                     // handle date formating for datetime fields
                     switch ($whereField['type']) {
                         case 'datetimecombo':
                         case 'datetime':
                             if (isset($whereField['valuekey'])) {
                                 $valKeyArray = explode(' ', $whereField['valuekey']);
                                 $whereField['value'] = $GLOBALS['timedate']->to_display_date($valKeyArray[0]) . ' ' . $valKeyArray[1];
                             }
                             if (isset($whereField['valuetokey'])) {
                                 $valKeyArray = explode(' ', $whereField['valuetokey']);
                                 $whereField['valueto'] = $GLOBALS['timedate']->to_display_date($valKeyArray[0]) . ' ' . $valKeyArray[1];
                             }
                             break;
                         case 'date':
                             if (isset($whereField['valuekey'])) {
                                 $whereField['value'] = $GLOBALS['timedate']->to_display_date($whereField['valuekey']);
                             }
                     }
                     break;
             }
             // return the Fields
             $editableWhereFields[] = $whereField;
         }
     }
     return $editableWhereFields;
 }