From a39efd67fa985616c832caf6046882291ff033ff Mon Sep 17 00:00:00 2001 From: "chaitanya@vtiger.com" <chaitanya@vtiger.com> Date: Wed, 12 Jun 2024 10:53:05 +0530 Subject: [PATCH] E_ALL cleanups in Reports module --- data/CRMEntity.php | 4 ++-- include/utils/VTCacheUtils.php | 2 +- layouts/v7/modules/Reports/ChartEditStep2.tpl | 5 ++++- layouts/v7/modules/Reports/ModuleHeader.tpl | 10 ++++++---- layouts/v7/modules/Reports/RelatedFields.tpl | 8 ++++---- layouts/v7/modules/Reports/ReportContents.tpl | 4 ++-- layouts/v7/modules/Reports/ScheduleReport.tpl | 4 ++-- layouts/v7/modules/Reports/Step1.tpl | 8 ++++++-- layouts/v7/modules/Reports/step2.tpl | 8 +++++--- layouts/v7/modules/Reports/step3.tpl | 3 +++ layouts/v7/modules/Vtiger/AdvanceFilter.tpl | 4 ++-- modules/Reports/ReportRun.php | 8 ++++++-- modules/Reports/ReportUtils.php | 16 +++++++++------- modules/Reports/Reports.php | 18 +++++++++++------- modules/Reports/actions/DeleteAjax.php | 1 + modules/Reports/actions/MoveReports.php | 1 + modules/Reports/models/Folder.php | 9 +++++---- modules/Reports/models/Module.php | 2 +- modules/Reports/models/Record.php | 2 +- modules/Reports/models/RecordStructure.php | 3 +++ modules/Reports/models/Report.php | 2 ++ modules/Reports/views/Detail.php | 4 ++-- modules/Reports/views/Edit.php | 2 +- 23 files changed, 80 insertions(+), 48 deletions(-) diff --git a/data/CRMEntity.php b/data/CRMEntity.php index ae8239f3b..cdb158b58 100644 --- a/data/CRMEntity.php +++ b/data/CRMEntity.php @@ -2430,7 +2430,7 @@ class CRMEntity { $fields[] = $value; } $pritablename = $tables[0]; - $sectablename = $tables[1]; + $sectablename = isset($tables[1]) ? $tables[1] : ''; $prifieldname = $fields[0][0]; $secfieldname = $fields[0][1]; $tmpname = $pritablename . 'tmp' . $secmodule; @@ -2470,7 +2470,7 @@ class CRMEntity { $secQuery = 'SELECT '.$selectColumns.' '.$secQueryFrom; - $secQueryTempTableQuery = $queryPlanner->registerTempTable($secQuery, array($column_name, $fields[1], $prifieldname),$secmodule); + $secQueryTempTableQuery = $queryPlanner->registerTempTable($secQuery, array($column_name, isset($fields[1]) ? $fields[1] : '', $prifieldname),$secmodule); $query = ''; if ($pritablename == 'vtiger_crmentityrel') { diff --git a/include/utils/VTCacheUtils.php b/include/utils/VTCacheUtils.php index 3a286e03c..23b3cf23d 100644 --- a/include/utils/VTCacheUtils.php +++ b/include/utils/VTCacheUtils.php @@ -441,7 +441,7 @@ class VTCacheUtils { static $_report_field_bylabel = array(); public static function getReportFieldByLabel($module, $label) { - return self::$_report_field_bylabel[$module][$label]; + return isset(self::$_report_field_bylabel[$module][$label]) ? self::$_report_field_bylabel[$module][$label] : array(); } public static function setReportFieldByLabel($module, $label, $fieldInfo) { diff --git a/layouts/v7/modules/Reports/ChartEditStep2.tpl b/layouts/v7/modules/Reports/ChartEditStep2.tpl index 4eb05155c..a21362e2c 100644 --- a/layouts/v7/modules/Reports/ChartEditStep2.tpl +++ b/layouts/v7/modules/Reports/ChartEditStep2.tpl @@ -39,7 +39,7 @@ {foreach key=BLOCK_LABEL item=BLOCK_FIELDS from=$PRIMARY_MODULE_RECORD_STRUCTURE} {assign var=PRIMARY_MODULE_BLOCK_LABEL value=vtranslate($BLOCK_LABEL, $PRIMARY_MODULE)} {assign var=key value="$PRIMARY_MODULE_LABEL $PRIMARY_MODULE_BLOCK_LABEL"} - {if $LINEITEM_FIELD_IN_CALCULATION eq false && $BLOCK_LABEL eq 'LBL_ITEM_DETAILS'} + {if isset($LINEITEM_FIELD_IN_CALCULATION) && $LINEITEM_FIELD_IN_CALCULATION eq false && $BLOCK_LABEL eq 'LBL_ITEM_DETAILS'} {* dont show the line item fields block when Inventory fields are selected for calculations *} {else} {$RECORD_STRUCTURE[$key] = $BLOCK_FIELDS} @@ -58,6 +58,9 @@ <h4><strong>{vtranslate('LBL_CHOOSE_FILTER_CONDITIONS',$MODULE)}</strong></h4> <br> <span class="col-lg-12"> + {if !isset($SELECTED_ADVANCED_FILTER_FIELDS)} + {assign var="SELECTED_ADVANCED_FILTER_FIELDS" value=array()} + {/if} {include file='AdvanceFilter.tpl'|@vtemplate_path RECORD_STRUCTURE=$RECORD_STRUCTURE ADVANCE_CRITERIA=$SELECTED_ADVANCED_FILTER_FIELDS COLUMNNAME_API=getReportFilterColumnName} </span> </div> diff --git a/layouts/v7/modules/Reports/ModuleHeader.tpl b/layouts/v7/modules/Reports/ModuleHeader.tpl index 05f63e346..fd42f20c0 100644 --- a/layouts/v7/modules/Reports/ModuleHeader.tpl +++ b/layouts/v7/modules/Reports/ModuleHeader.tpl @@ -36,7 +36,7 @@ </p> </span> - {if $VIEWNAME} + {if isset($VIEWNAME) && $VIEWNAME} {if $VIEWNAME neq 'All'} {foreach item=FOLDER from=$FOLDERS} {if $FOLDER->getId() eq $VIEWNAME} @@ -55,6 +55,7 @@ <span class="col-lg-5 col-md-5 pull-right"> <div id="appnav" class="navbar-right"> + {if isset($LISTVIEW_LINKS['LISTVIEWBASIC'])} {foreach item=LISTVIEW_BASICACTION from=$LISTVIEW_LINKS['LISTVIEWBASIC']} {assign var="childLinks" value=$LISTVIEW_BASICACTION->getChildLinks()} {if $childLinks && $LISTVIEW_BASICACTION->get('linklabel') == 'LBL_ADD_RECORD'} @@ -71,15 +72,16 @@ {elseif $childLink->getLabel() eq 'LBL_DETAIL_REPORT'} {assign var="ICON_CLASS" value='vicon-detailreport'} {/if} - <li id="{$MODULE}_listView_basicAction_{Vtiger_Util_Helper::replaceSpaceWithUnderScores($childLink->getLabel())}" {if isset($childLink->disabled)} data-edition-disable="{$childLink->disabled}" {/if} - {if isset($childLink->message)} data-edition-message="{$childLink->message}" {/if}> - <a {if isset($childLink->disabled) && $childLink->disabled neq '1'} {if stripos($childLink->getUrl(), 'javascript:') === 0} onclick='{$childLink->getUrl()|substr:strlen("javascript:")};' {else} href='{$childLink->getUrl()}' {/if} {else} href="javascript:void(0);" {/if}><i class='{$ICON_CLASS}' style="font-size:13px;"></i> {vtranslate($childLink->getLabel(), $MODULE)}</a> + <li id="{$MODULE}_listView_basicAction_{Vtiger_Util_Helper::replaceSpaceWithUnderScores($childLink->getLabel())}" data-edition-disable="{$childLink->disabled}" + data-edition-message="{$childLink->message}"> + <a {if $childLink->disabled neq '1'} {if stripos($childLink->getUrl(), 'javascript:') === 0} onclick='{$childLink->getUrl()|substr:strlen("javascript:")};' {else} href='{$childLink->getUrl()}' {/if} {else} href="javascript:void(0);" {/if}><i class='{$ICON_CLASS}' style="font-size:13px;"></i> {vtranslate($childLink->getLabel(), $MODULE)}</a> </li> {/foreach} </ul> </span> {/if} {/foreach} + {/if} </div> </span> </div> diff --git a/layouts/v7/modules/Reports/RelatedFields.tpl b/layouts/v7/modules/Reports/RelatedFields.tpl index 75ccfee05..637c32b3b 100644 --- a/layouts/v7/modules/Reports/RelatedFields.tpl +++ b/layouts/v7/modules/Reports/RelatedFields.tpl @@ -18,7 +18,7 @@ {foreach key=BLOCK_LABEL item=BLOCK from=$PRIMARY_MODULE} <optgroup label='{vtranslate($PRIMARY_MODULE_NAME,$MODULE)}-{vtranslate($BLOCK_LABEL,$PRIMARY_MODULE_NAME)}'> {foreach key=FIELD_KEY item=FIELD_LABEL from=$BLOCK} - <option value="{$FIELD_KEY}"{if $FIELD_KEY eq $SELECTED_SORT_FIELD_KEY}selected=""{/if}>{vtranslate($FIELD_LABEL, $PRIMARY_MODULE_NAME)}</option> + <option value="{$FIELD_KEY}"{if isset($SELECTED_SORT_FIELD_KEY) && $FIELD_KEY eq $SELECTED_SORT_FIELD_KEY}selected=""{/if}>{vtranslate($FIELD_LABEL, $PRIMARY_MODULE_NAME)}</option> {/foreach} </optgroup> {/foreach} @@ -27,7 +27,7 @@ {foreach key=BLOCK_LABEL item=BLOCK from=$SECONDARY_MODULE} <optgroup label='{vtranslate($SECONDARY_MODULE_NAME,$MODULE)}-{vtranslate($BLOCK_LABEL,$SECONDARY_MODULE_NAME)}'> {foreach key=FIELD_KEY item=FIELD_LABEL from=$BLOCK} - <option value="{$FIELD_KEY}"{if $FIELD_KEY eq $SELECTED_SORT_FIELD_KEY}selected=""{/if}>{vtranslate($FIELD_LABEL, $SECONDARY_MODULE_NAME)}</option> + <option value="{$FIELD_KEY}"{if isset($SELECTED_SORT_FIELD_KEY) && $FIELD_KEY eq $SELECTED_SORT_FIELD_KEY}selected=""{/if}>{vtranslate($FIELD_LABEL, $SECONDARY_MODULE_NAME)}</option> {/foreach} </optgroup> {/foreach} @@ -39,8 +39,8 @@ <div class="row"> <span class="col-lg-6"> {assign var=ROW value='row_'|cat:$ROW_VAL} - <input type="radio" name="{$ROW}" class="sortOrder" value="Ascending" {if $SELECTED_SORT_FIELD_VALUE eq Ascending} checked="" {/if} /> <span>{vtranslate('LBL_ASCENDING',$MODULE)}</span> - <input type="radio" name="{$ROW}" class="sortOrder" value="Descending" {if $SELECTED_SORT_FIELD_VALUE eq Descending} checked="" {/if}/> <span>{vtranslate('LBL_DESCENDING',$MODULE)}</span> + <input type="radio" name="{$ROW}" class="sortOrder" value="Ascending" {if isset($SELECTED_SORT_FIELD_VALUE) && $SELECTED_SORT_FIELD_VALUE eq Ascending} checked="" {/if} /> <span>{vtranslate('LBL_ASCENDING',$MODULE)}</span> + <input type="radio" name="{$ROW}" class="sortOrder" value="Descending" {if isset($SELECTED_SORT_FIELD_VALUE) && $SELECTED_SORT_FIELD_VALUE eq Descending} checked="" {/if}/> <span>{vtranslate('LBL_DESCENDING',$MODULE)}</span> </span> </div> </span> diff --git a/layouts/v7/modules/Reports/ReportContents.tpl b/layouts/v7/modules/Reports/ReportContents.tpl index a9e1c9172..ee93270cd 100644 --- a/layouts/v7/modules/Reports/ReportContents.tpl +++ b/layouts/v7/modules/Reports/ReportContents.tpl @@ -48,7 +48,7 @@ </div> <div id="reportDetails" class="contents-bottomscroll"> <div class="bottomscroll-div"> - <input type="hidden" id="updatedCount" value="{$NEW_COUNT}" /> + <input type="hidden" id="updatedCount" value="{if isset($NEW_COUNT)}{$NEW_COUNT}{else}''{/if}" /> {if $DATA neq ''} {assign var=HEADERS value=$DATA[0]} <table class="table table-bordered"> @@ -139,7 +139,7 @@ {/foreach} {/if} </table> - {if $LIMIT_EXCEEDED} + {if isset($LIMIT_EXCEEDED) && $LIMIT_EXCEEDED} <center>{vtranslate('LBL_LIMIT_EXCEEDED',$MODULE)} <span class="pull-right"><a href="#top" >{vtranslate('LBL_TOP',$MODULE)}</a></span></center> {/if} {else} diff --git a/layouts/v7/modules/Reports/ScheduleReport.tpl b/layouts/v7/modules/Reports/ScheduleReport.tpl index d60695a0c..6544a025d 100644 --- a/layouts/v7/modules/Reports/ScheduleReport.tpl +++ b/layouts/v7/modules/Reports/ScheduleReport.tpl @@ -67,8 +67,8 @@ <div class='col-lg-2'> <div class="input-group inputElement date" style="margin-bottom: 3px"> {assign var=specificDate value=Zend_Json::decode($SCHEDULEDREPORTS->get('schdate'))} - {if $specificDate[0] neq ''} {assign var=specificDate1 value=DateTimeField::convertToUserFormat($specificDate[0])} {/if} - <input style='width: 185px;' type="text" class="dateField form-control" id="schdate" name="schdate" value="{$specificDate1}" data-date-format="{$CURRENT_USER->date_format}" data-rule-required="true" /> + {if isset($specificDate[0]) && $specificDate[0] neq ''} {assign var=specificDate1 value=DateTimeField::convertToUserFormat($specificDate[0])} {/if} + <input style='width: 185px;' type="text" class="dateField form-control" id="schdate" name="schdate" value="{if isset($specificDate1)}{$specificDate1}{else}''{/if}" data-date-format="{$CURRENT_USER->date_format}" data-rule-required="true" /> <span class="input-group-addon"><i class="fa fa-calendar "></i></span> </div> </div> diff --git a/layouts/v7/modules/Reports/Step1.tpl b/layouts/v7/modules/Reports/Step1.tpl index f58aa9cf4..26ba4b26b 100644 --- a/layouts/v7/modules/Reports/Step1.tpl +++ b/layouts/v7/modules/Reports/Step1.tpl @@ -18,7 +18,7 @@ <input type="hidden" name="module" value="{$MODULE}" /> <input type="hidden" name="view" value="{$VIEW}" /> <input type="hidden" class="step" value="1" /> - <input type="hidden" name="isDuplicate" value="{$IS_DUPLICATE}" /> + <input type="hidden" name="isDuplicate" value="{if isset($IS_DUPLICATE)}{$IS_DUPLICATE}{else}false{/if}" /> <input type="hidden" name="record" value="{$RECORD_ID}" /> <input type=hidden id="relatedModules" data-value='{ZEND_JSON::encode($RELATED_MODULES)}' /> <div style="border:1px solid #ccc;padding:4%;"> @@ -68,7 +68,11 @@ <div class="form-group"> <label class="col-lg-3 control-label textAlignLeft">{vtranslate('LBL_SELECT_RELATED_MODULES',$MODULE)} ({vtranslate('LBL_MAX',$MODULE)} 2)</label> <div class="col-lg-4"> - {assign var=SECONDARY_MODULES_ARR value=explode(':',$REPORT_MODEL->getSecondaryModules())} + {if $REPORT_MODEL->getSecondaryModules() neq null && $REPORT_MODEL->getSecondaryModules() neq ''} + {assign var="SECONDARY_MODULES_ARR" value=explode(':', $REPORT_MODEL->getSecondaryModules())} + {else} + {assign var="SECONDARY_MODULES_ARR" value=[]} + {/if} {assign var=PRIMARY_MODULE value=$REPORT_MODEL->getPrimaryModule()} {if $PRIMARY_MODULE eq ''} diff --git a/layouts/v7/modules/Reports/step2.tpl b/layouts/v7/modules/Reports/step2.tpl index 94935b08d..6add2c6ee 100644 --- a/layouts/v7/modules/Reports/step2.tpl +++ b/layouts/v7/modules/Reports/step2.tpl @@ -23,7 +23,7 @@ <input type="hidden" name="description" value="{$REPORT_MODEL->get('description')}" /> <input type="hidden" name="primary_module" value="{$PRIMARY_MODULE}" /> <input type="hidden" name="secondary_modules" value={ZEND_JSON::encode($SECONDARY_MODULES)} /> - <input type="hidden" name="selected_fields" id="seleted_fields" value='{ZEND_JSON::encode($SELECTED_FIELDS)}' /> + <input type="hidden" name="selected_fields" id="selected_fields" value='{if isset($SELECTED_FIELDS)}{ZEND_JSON::encode($SELECTED_FIELDS)}{/if}' /> <input type="hidden" name="selected_sort_fields" id="selected_sort_fields" value="" /> <input type="hidden" name="calculation_fields" id="calculation_fields" value="" /> <input type="hidden" name="isDuplicate" value="{$IS_DUPLICATE}" /> @@ -71,14 +71,16 @@ </div> <div class=""> {assign var=ROW_VAL value=1} + {if isset($SELECTED_SORT_FIELDS) && is_array($SELECTED_SORT_FIELDS)} {foreach key=SELECTED_SORT_FIELD_KEY item=SELECTED_SORT_FIELD_VALUE from=$SELECTED_SORT_FIELDS} <div class="row sortFieldRow" style="padding-bottom:10px;"> {include file='RelatedFields.tpl'|@vtemplate_path:$MODULE ROW_VAL=$ROW_VAL} {assign var=ROW_VAL value=($ROW_VAL+1)} </div> {/foreach} - {assign var=SELECTED_SORT_FEILDS_ARRAY value=$SELECTED_SORT_FIELDS} - {assign var=SELECTED_SORT_FIELDS_COUNT value=php7_count($SELECTED_SORT_FEILDS_ARRAY)} + {/if} + {assign var=SELECTED_SORT_FEILDS_ARRAY value=(isset($SELECTED_SORT_FIELDS))?$SELECTED_SORT_FIELDS:array()} + {assign var=SELECTED_SORT_FIELDS_COUNT value=(isset($SELECTED_SORT_FEILDS_ARRAY))?php7_count($SELECTED_SORT_FEILDS_ARRAY):array()} {while $SELECTED_SORT_FIELDS_COUNT lt 3 } <div class="row sortFieldRow" style="padding-bottom:10px;"> {include file='RelatedFields.tpl'|@vtemplate_path:$MODULE ROW_VAL=$ROW_VAL} diff --git a/layouts/v7/modules/Reports/step3.tpl b/layouts/v7/modules/Reports/step3.tpl index 3f287d2e0..524a8e791 100644 --- a/layouts/v7/modules/Reports/step3.tpl +++ b/layouts/v7/modules/Reports/step3.tpl @@ -64,6 +64,9 @@ <h4><strong>{vtranslate('LBL_CHOOSE_FILTER_CONDITIONS',$MODULE)}</strong></h4> <br> <span class="col-lg-12"> + {if !isset($SELECTED_ADVANCED_FILTER_FIELDS)} + {assign var="SELECTED_ADVANCED_FILTER_FIELDS" value=array()} + {/if} {include file='AdvanceFilter.tpl'|@vtemplate_path RECORD_STRUCTURE=$RECORD_STRUCTURE ADVANCE_CRITERIA=$SELECTED_ADVANCED_FILTER_FIELDS COLUMNNAME_API=getReportFilterColumnName} </span> </div> diff --git a/layouts/v7/modules/Vtiger/AdvanceFilter.tpl b/layouts/v7/modules/Vtiger/AdvanceFilter.tpl index 50048b7f0..5b79b1712 100644 --- a/layouts/v7/modules/Vtiger/AdvanceFilter.tpl +++ b/layouts/v7/modules/Vtiger/AdvanceFilter.tpl @@ -10,8 +10,8 @@ ********************************************************************************/ -->*} {strip} - {assign var=ALL_CONDITION_CRITERIA value=(isset($ADVANCE_CRITERIA[1])?$ADVANCE_CRITERIA[1]:[])} - {assign var=ANY_CONDITION_CRITERIA value=(isset($ADVANCE_CRITERIA[2])?$ADVANCE_CRITERIA[2]:[])} + {assign var=ALL_CONDITION_CRITERIA value=(isset($ADVANCE_CRITERIA[1]))?$ADVANCE_CRITERIA[1]:[]} + {assign var=ANY_CONDITION_CRITERIA value=(isset($ADVANCE_CRITERIA[2]))?$ADVANCE_CRITERIA[2]:[]} {if empty($ALL_CONDITION_CRITERIA) } {assign var=ALL_CONDITION_CRITERIA value=array()} diff --git a/modules/Reports/ReportRun.php b/modules/Reports/ReportRun.php index 9b14f2531..4a8bb1098 100644 --- a/modules/Reports/ReportRun.php +++ b/modules/Reports/ReportRun.php @@ -341,6 +341,9 @@ class ReportRun extends CRMEntity { } public static function getInstance($reportid) { + if (self::$instances === false || !is_array(self::$instances)) { + self::$instances = array(); + } if (!isset(self::$instances[$reportid])) { self::$instances[$reportid] = new ReportRun($reportid); } @@ -732,7 +735,7 @@ class ReportRun extends CRMEntity { * returns the case query for the escaped columns */ function getEscapedColumns($selectedfields) { - + $queryColumn = ''; $tableName = $selectedfields[0]; $columnName = $selectedfields[1]; $moduleFieldLabel = $selectedfields[2]; @@ -2999,7 +3002,7 @@ class ReportRun extends CRMEntity { $allColumnsRestricted = false; if ($type == 'COLUMNSTOTOTAL') { - if ($columnstotalsql != '') { + if (isset($columnstotalsql) && $columnstotalsql != '') { $reportquery = "select " . $columnstotalsql . " " . $reportquery . " " . $wheresql; } } else { @@ -3074,6 +3077,7 @@ class ReportRun extends CRMEntity { global $mod_strings, $current_language; require('user_privileges/user_privileges_' . $current_user->id . '.php'); $modules_selected = array(); + $picklistarray = array(); static $mod_query_details = array(); $modules_selected[] = $this->primarymodule; if (!empty($this->secondarymodule)) { diff --git a/modules/Reports/ReportUtils.php b/modules/Reports/ReportUtils.php index d0a18bd77..9fbda724d 100644 --- a/modules/Reports/ReportUtils.php +++ b/modules/Reports/ReportUtils.php @@ -64,11 +64,13 @@ function isReferenceUIType($uitype) { } function IsDateField($reportColDetails) { - list($tablename, $colname, $module_field, $fieldname, $typeOfData) = explode(':', $reportColDetails); - if ($typeOfData == "D") { - return true; - } else { - return false; + if (substr_count($reportColDetails, ':') >= 4) { + list($tablename, $colname, $module_field, $fieldname, $typeOfData) = explode(':', $reportColDetails); + if ($typeOfData == "D") { + return true; + } else { + return false; + } } } @@ -113,7 +115,7 @@ function getReportFieldValue ($report, $picklistArray, $dbField, $valueArray, $f $field = WebserviceField::fromArray($db, $fieldInfo); $fieldType = $field->getFieldDataType(); } - if(is_object($field) && $field->getUIType() == 401){ + if(isset($field) && is_object($field) && $field->getUIType() == 401){ if ($value) { $value = explode('_', $value); $module = 'RecurringInvoice'; @@ -255,7 +257,7 @@ function getReportFieldValue ($report, $picklistArray, $dbField, $valueArray, $f } // Added to render html tag for description fields - if($fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) { + if(isset($fieldInfo['uitype']) && $fieldInfo['uitype'] == '19' && ($module == 'Documents' || $module == 'Emails')) { return $fieldvalue; } if($operation == 'ExcelExport') { diff --git a/modules/Reports/Reports.php b/modules/Reports/Reports.php index 3bbc1d49c..1dd9f3e39 100644 --- a/modules/Reports/Reports.php +++ b/modules/Reports/Reports.php @@ -112,6 +112,7 @@ class Reports extends CRMEntity{ */ function __construct($reportid="") { global $adb,$current_user,$theme,$mod_strings; + $is_admin = false; $this->initListOfModules(); if($reportid != "") { @@ -584,7 +585,7 @@ class Reports extends CRMEntity{ }while($report = $adb->fetch_array($result)); } if($rpt_fldr_id !== false && $rpt_fldr_id !== 'shared' && $rpt_fldr_id !== 'All') { - $returndata = $returndata[$rpt_fldr_id]; + $returndata = isset($returndata[$rpt_fldr_id]) ? $returndata[$rpt_fldr_id] : ''; } $log->info("Reports :: ListView->Successfully returned vtiger_report details HTML"); return $returndata; @@ -613,9 +614,10 @@ class Reports extends CRMEntity{ function getPriModuleColumnsList($module) { //$this->updateModuleList($module); - $allColumnsListByBlocks =& $this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true); + $tempColumnsListByBlocks =$this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true); + $allColumnsListByBlocks = & $tempColumnsListByBlocks; foreach($this->module_list[$module] as $key=>$value) { - $temp = $allColumnsListByBlocks[$key]; + $temp = isset($allColumnsListByBlocks[$key]) ? $allColumnsListByBlocks[$key] : array(); if (!empty($ret_module_list[$module][$value])) { if (!empty($temp)) { @@ -684,7 +686,7 @@ class Reports extends CRMEntity{ * @return Array */ public function getBlockFieldList($module, $blockIdList, $currentFieldList,$allColumnsListByBlocks) { - $temp = $allColumnsListByBlocks[$blockIdList]; + $temp = isset($allColumnsListByBlocks[$blockIdList]) ? $allColumnsListByBlocks[$blockIdList] : ''; if(!empty($currentFieldList)){ if(!empty($temp)){ $currentFieldList = array_merge($currentFieldList,$temp); @@ -696,10 +698,12 @@ class Reports extends CRMEntity{ } public function getModuleFieldList($module) { - $allColumnsListByBlocks =& $this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true); + $ret_module_list = array(); + $tempColumnsListByBlocks =$this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true); + $allColumnsListByBlocks = & $tempColumnsListByBlocks; foreach($this->module_list[$module] as $key=>$value) { $ret_module_list[$module][$value] = $this->getBlockFieldList( - $module, $key, $ret_module_list[$module][$value],$allColumnsListByBlocks); + $module, $key, isset($ret_module_list[$module][$value]) ? $ret_module_list[$module][$value] : array(),$allColumnsListByBlocks); } return $ret_module_list[$module]; } @@ -807,7 +811,7 @@ class Reports extends CRMEntity{ $optionvalue = $fieldtablename.":".$fieldcolname.":".$module."_".$fieldlabel1.":".$fieldname.":".$fieldtypeofdata; $adv_rel_field_tod_value = '$'.$module.'#'.$fieldname.'$'."::".getTranslatedString($module,$module)." ".getTranslatedString($fieldlabel,$module); - if (!is_array($this->adv_rel_fields[$fieldtypeofdata]) || + if (!isset($this->adv_rel_fields[$fieldtypeofdata]) || !is_array($this->adv_rel_fields[$fieldtypeofdata]) || !in_array($adv_rel_field_tod_value, $this->adv_rel_fields[$fieldtypeofdata])) { $this->adv_rel_fields[$fieldtypeofdata][] = $adv_rel_field_tod_value; } diff --git a/modules/Reports/actions/DeleteAjax.php b/modules/Reports/actions/DeleteAjax.php index b1c5ab0b9..70d178f88 100644 --- a/modules/Reports/actions/DeleteAjax.php +++ b/modules/Reports/actions/DeleteAjax.php @@ -20,6 +20,7 @@ class Reports_DeleteAjax_Action extends Vtiger_DeleteAjax_Action { public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $recordId = $request->get('record'); + $parentModule = ''; $response = new Vtiger_Response(); $recordModel = Reports_Record_Model::getInstanceById($recordId, $moduleName); diff --git a/modules/Reports/actions/MoveReports.php b/modules/Reports/actions/MoveReports.php index 7e203c46a..27c4a04b9 100644 --- a/modules/Reports/actions/MoveReports.php +++ b/modules/Reports/actions/MoveReports.php @@ -18,6 +18,7 @@ class Reports_MoveReports_Action extends Vtiger_Mass_Action { public function process(Vtiger_Request $request) { $parentModule = 'Reports'; + $sameTargetFolder = 0; $reportIdsList = $this->getRecordsListFromRequest($request); $folderId = $request->get('folderid'); $viewname=$request->get('viewname'); diff --git a/modules/Reports/models/Folder.php b/modules/Reports/models/Folder.php index 896abdab5..9075ed032 100644 --- a/modules/Reports/models/Folder.php +++ b/modules/Reports/models/Folder.php @@ -113,10 +113,11 @@ class Reports_Folder_Model extends Vtiger_Base_Model { $reportModels = array(); for($i=0; $i < php7_count($reportsList); $i++) { $reportModel = Reports_Record_Model::getCleanInstance(); - - $reportModel->setData($reportsList[$i])->setModuleFromInstance($reportModuleModel); - $reportModels[] = $reportModel; - unset($reportModel); + if (isset($reportsList[$i]) && is_array($reportsList)) { + $reportModel->setData($reportsList[$i])->setModuleFromInstance($reportModuleModel); + $reportModels[] = $reportModel; + unset($reportModel); + } } return $reportModels; } diff --git a/modules/Reports/models/Module.php b/modules/Reports/models/Module.php index b35ea0b09..4fc3eee22 100644 --- a/modules/Reports/models/Module.php +++ b/modules/Reports/models/Module.php @@ -17,7 +17,7 @@ class Reports_Module_Model extends Vtiger_Module_Model { function deleteRecord(Vtiger_Record_Model $reportModel) { $currentUser = Users_Record_Model::getCurrentUserModel(); $subOrdinateUsers = $currentUser->getSubordinateUsers(); - + $homePageChartIdsList = array(); $subOrdinates = array(); foreach($subOrdinateUsers as $id=>$name) { $subOrdinates[] = $id; diff --git a/modules/Reports/models/Record.php b/modules/Reports/models/Record.php index a88e21a95..098478e84 100644 --- a/modules/Reports/models/Record.php +++ b/modules/Reports/models/Record.php @@ -51,7 +51,7 @@ class Reports_Record_Model extends Vtiger_Record_Model { * @return type */ public function getMembers() { - if($this->members == false) { + if(!property_exists($this, 'members') || $this->members == false) { $this->members = Settings_Groups_Member_Model::getAllByGroup($this, Settings_Groups_Member_Model::REPORTS_VIEW_MODE); } return $this->members; diff --git a/modules/Reports/models/RecordStructure.php b/modules/Reports/models/RecordStructure.php index f40d13f53..489b37355 100644 --- a/modules/Reports/models/RecordStructure.php +++ b/modules/Reports/models/RecordStructure.php @@ -80,6 +80,9 @@ class Reports_RecordStructure_Model extends Vtiger_RecordStructure_Model { } } } + if ($this->structuredValues === false) { + $this->structuredValues = array(); + } $this->structuredValues[$moduleName] = $moduleRecordStructure; return $moduleRecordStructure; } diff --git a/modules/Reports/models/Report.php b/modules/Reports/models/Report.php index 4ab553e92..2fafe65d4 100644 --- a/modules/Reports/models/Report.php +++ b/modules/Reports/models/Report.php @@ -21,6 +21,8 @@ class Vtiger_Report_Model extends Reports { $currentUser = Users_Record_Model::getCurrentUserModel(); $userId = $currentUser->getId(); $currentUserRoleId = $currentUser->get('roleid'); + $userGroupsQuery = ''; + $current_user_parent_role_seq = ''; $subordinateRoles = getRoleSubordinates($currentUserRoleId); array_push($subordinateRoles, $currentUserRoleId); diff --git a/modules/Reports/views/Detail.php b/modules/Reports/views/Detail.php index 22c0b28e3..66d35d8cd 100644 --- a/modules/Reports/views/Detail.php +++ b/modules/Reports/views/Detail.php @@ -58,7 +58,7 @@ class Reports_Detail_View extends Vtiger_Index_View { $pagingModel->set('limit', self::REPORT_LIMIT); $reportData = $reportModel->getReportData($pagingModel); - $this->reportData = $reportData['data']; + $this->reportData = isset($reportData['data']) ? $reportData['data'] : ''; $this->calculationFields = $reportModel->getReportCalulationData(); $this->count = $reportData['count']; @@ -182,7 +182,7 @@ class Reports_Detail_View extends Vtiger_Index_View { $reportType = $reportModel->get('reporttype'); $reportData = $reportModel->getReportData($pagingModel); - $data = $reportData['data']; + $data = isset($reportData['data']) ? $reportData['data'] : ''; $this->count = $reportData['count']; $calculation = $reportModel->getReportCalulationData(); } diff --git a/modules/Reports/views/Edit.php b/modules/Reports/views/Edit.php index f90d9814f..4f752936c 100644 --- a/modules/Reports/views/Edit.php +++ b/modules/Reports/views/Edit.php @@ -198,7 +198,7 @@ Class Reports_Edit_View extends Vtiger_Edit_View { foreach($secondaryModuleFields as $module => $blockFields){ if($module == 'HelpDesk'){ foreach($blockFields as $key => $value){ - if(isset($value)){ + if(isset($value) && is_array($value)){ foreach($value as $key1 => $value1){ if($key1 == 'vtiger_troubletickets:update_log:HelpDesk_Update_History:update_log:V'){ unset($secondaryModuleFields[$module][$key][$key1]); -- GitLab