diff --git a/data/CRMEntity.php b/data/CRMEntity.php
index ae8239f3b22a91023c58734766e92c3c68145310..cdb158b583de0a88e5efcd3871e71d9aa41f6dcd 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 3a286e03c386935e05e85e0040674252f4086dd7..23b3cf23ded052679d504384cdbd3ced0b9b58bf 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/includes/runtime/LanguageHandler.php b/includes/runtime/LanguageHandler.php
index b570bd7adaefab7ce0cdba42cfe52fd817c45bb3..b5c894e852a377d455ae49ef1dbef12e152a4601 100644
--- a/includes/runtime/LanguageHandler.php
+++ b/includes/runtime/LanguageHandler.php
@@ -58,7 +58,9 @@ class Vtiger_Language_Handler {
 	public static function getLanguageTranslatedString($language, $key, $module = '') {
 		$moduleStrings = array();
 
-		$module = str_replace(':', '.', $module);
+		if ($module !== null) {
+			$module = str_replace(':', '.', $module);
+		}
 		if (is_array($module))
 			return null;
 		$moduleStrings = self::getModuleStringsFromFile($language, $module);
@@ -66,7 +68,7 @@ class Vtiger_Language_Handler {
 			return $moduleStrings['languageStrings'][$key];
 		}
 		// Lookup for the translation in base module, in case of sub modules, before ending up with common strings
-		if (strpos($module, '.') > 0) {
+		if ($module != null && strpos($module, '.') > 0) {
 			$baseModule = substr($module, 0, strpos($module, '.'));
 			if ($baseModule == 'Settings') {
 				$baseModule = 'Settings.Vtiger';
@@ -124,7 +126,7 @@ class Vtiger_Language_Handler {
 	 * @return <array> - array if module has language strings else returns empty array
 	 */
 	public static function getModuleStringsFromFile($language, $module='Vtiger'){
-		$module = str_replace(':', '.', $module);
+		if($module !== null) $module = str_replace(':', '.', $module);
 		if (!empty(self::$languageContainer[$language][$module])) {
 		    return self::$languageContainer[$language][$module];
 		}
diff --git a/includes/runtime/Viewer.php b/includes/runtime/Viewer.php
index d7b41cc89ce2860d240d15c303552fe24ac45f97..3ac034c25de6957a243eb8e499f8d09e2ecff2bf 100644
--- a/includes/runtime/Viewer.php
+++ b/includes/runtime/Viewer.php
@@ -78,7 +78,7 @@ class Vtiger_Viewer extends Smarty {
 			'Vtiger_Theme', 'Users_Record_Model', 'Vtiger_Module_Model', 'Vtiger_Field_Model', 'Vtiger_Record_Model',
 			'Settings_Picklist_Module_Model', 'CustomView_Record_Model', 'Vtiger_Extension_View',
 			'Vtiger_Tag_Model', 'Settings_Vtiger_Module_Model', 'PBXManager_Server_Model',
-			'Vtiger_Functions', 'Users', 'CurrencyField');
+			'Vtiger_Functions', 'Users', 'CurrencyField', 'Reports_Field_Model');
 		foreach ($classes as $clazz) {
 			if (class_exists($clazz)) {
 				$this->registerClass($clazz, $clazz);
diff --git a/layouts/v7/modules/Reports/ChartEditStep2.tpl b/layouts/v7/modules/Reports/ChartEditStep2.tpl
index 4eb05155ca7241cef23c3c0987eef1d1971faaa0..a21362e2cb54a9ffc2aaa9a2595b9a4a87bc8f1c 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/ChartReportContents.tpl b/layouts/v7/modules/Reports/ChartReportContents.tpl
index 8db5afd0007f1bd657049324bec58deead8aa151..2fb01128e85215ff409fbf8cdfce39148cdf7912 100644
--- a/layouts/v7/modules/Reports/ChartReportContents.tpl
+++ b/layouts/v7/modules/Reports/ChartReportContents.tpl
@@ -9,7 +9,7 @@
 
 <input type='hidden' name='charttype' value="{$CHART_TYPE}" />
 <input type='hidden' name='data' value='{Vtiger_Functions::jsonEncode($DATA)}' />
-<input type='hidden' name='clickthrough' value="{$CLICK_THROUGH}" />
+<input type='hidden' name='clickthrough' value="{if isset($CLICK_THROUGH)}{$CLICK_THROUGH}{else}false{/if}" />
 
 <br>
 <div class="dashboardWidgetContent">
@@ -17,7 +17,7 @@
     <div class='border1px filterConditionContainer' style="padding:30px;">
     <div id='chartcontent' name='chartcontent' style="min-height:500px overflowY:'auto';" data-mode='Reports'></div>
         <br>
-        {if $CLICK_THROUGH neq 'true'}
+        {if isset($CLICK_THROUGH) && $CLICK_THROUGH neq 'true'}
             <div class='row-fluid alert-info'>
                 <span class='col-lg-4 offset4'> &nbsp;</span>
                 <span class='span alert-info'>
diff --git a/layouts/v7/modules/Reports/ChartReportHeader.tpl b/layouts/v7/modules/Reports/ChartReportHeader.tpl
index 63ca2de8b2cf8f943864f5c337958589a2e8a8a9..9bce0fddd7228ac45c6856f0799410ad1f2de990 100644
--- a/layouts/v7/modules/Reports/ChartReportHeader.tpl
+++ b/layouts/v7/modules/Reports/ChartReportHeader.tpl
@@ -21,7 +21,7 @@
                     <input type="hidden" name="reports_description" value="{$REPORT_MODEL->get('reports_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="advanced_filter" id="advanced_filter" value={ZEND_JSON::encode($ADVANCED_FILTERS)} />
+                    <input type="hidden" name="advanced_filter" id="advanced_filter" value={if isset($ADVANCED_FILTERS)}{ZEND_JSON::encode($ADVANCED_FILTERS)}{else}''{/if} />
                     <input type="hidden" name='groupbyfield' value={$CHART_MODEL->getGroupByField()} />
                     <input type="hidden" name='datafields' value={Zend_JSON::encode($CHART_MODEL->getDataFields())} />
                     <input type="hidden" name='charttype' value="{$CHART_MODEL->getChartType()}" />
@@ -31,7 +31,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}
diff --git a/layouts/v7/modules/Reports/DetailViewActions.tpl b/layouts/v7/modules/Reports/DetailViewActions.tpl
index 1937a77d9ff7af958bd494de64e9ce1f28551534..0b587d226a73f8044b3404a2ca11c69292a31c89 100644
--- a/layouts/v7/modules/Reports/DetailViewActions.tpl
+++ b/layouts/v7/modules/Reports/DetailViewActions.tpl
@@ -71,12 +71,14 @@
 					<span class="pull-right">
 						<div class="btn-toolbar">
 							<div class="btn-group">
+							{if isset($DETAILVIEW_LINKS) && $DETAILVIEW_LINKS}
 								{foreach item=DETAILVIEW_LINK from=$DETAILVIEW_LINKS}
 									{assign var=LINKNAME value=$DETAILVIEW_LINK->getLabel()}
 									<button class="btn btn-default reportActions" name="{$LINKNAME}" data-href="{$DETAILVIEW_LINK->getUrl()}&source={$REPORT_MODEL->getReportType()}">
 										{$LINKNAME}
 									</button>
 								{/foreach}
+							{/if}
 							</div>
 						</div>
 					</span>
diff --git a/layouts/v7/modules/Reports/ListViewContents.tpl b/layouts/v7/modules/Reports/ListViewContents.tpl
index 23443068d578a5e66924f10424e74b940ecebbcd..7446a5b86726367c0f13064f86fbfdf4bb8d602a 100644
--- a/layouts/v7/modules/Reports/ListViewContents.tpl
+++ b/layouts/v7/modules/Reports/ListViewContents.tpl
@@ -14,7 +14,7 @@
 			<span class="essentials-toggle-marker fa {if $LEFTPANELHIDE eq '1'}fa-chevron-right{else}fa-chevron-left{/if} cursorPointer"></span>
 		</div>
 		<input type="hidden" name="view" id="view" value="{$VIEW}" />
-		<input type="hidden" name="cvid" value="{$VIEWID}" />
+		<input type="hidden" name="cvid" value="{(isset($VIEWID)) ? $VIEWID : ''}" />
 		<input type="hidden" name="pageStartRange" id="pageStartRange" value="{$PAGING_MODEL->getRecordStartRange()}" />
 		<input type="hidden" name="pageEndRange" id="pageEndRange" value="{$PAGING_MODEL->getRecordEndRange()}" />
 		<input type="hidden" name="previousPageExist" id="previousPageExist" value="{$PAGING_MODEL->isPrevPageExists()}" />
@@ -25,11 +25,11 @@
 		<input type='hidden' name="pageLimit" value="{$PAGING_MODEL->getPageLimit()}" id='pageLimit'>
 		<input type="hidden" name="noOfEntries" value="{$LISTVIEW_ENTRIES_COUNT}" id="noOfEntries">
 		<input type="hidden" name="currentSearchParams" value="{Vtiger_Util_Helper::toSafeHTML(Zend_JSON::encode($SEARCH_DETAILS))}" id="currentSearchParams" />
-		<input type="hidden" name="noFilterCache" value="{$NO_SEARCH_PARAMS_CACHE}" id="noFilterCache" >
+		<input type="hidden" name="noFilterCache" value="{(isset($NO_SEARCH_PARAMS_CACHE)) ? $NO_SEARCH_PARAMS_CACHE : ''}" id="noFilterCache" >
 		<input type="hidden" name="orderBy" value="{$ORDER_BY}" id="orderBy">
 		<input type="hidden" name="sortOrder" value="{$SORT_ORDER}" id="sortOrder">
-		<input type="hidden" name="list_headers" value='{$LIST_HEADER_FIELDS}'/>
-		<input type="hidden" name="tag" value="{$CURRENT_TAG}" />
+		<input type="hidden" name="list_headers" value='{(isset($LIST_HEADER_FIELDS)) ? $LIST_HEADER_FIELDS : ''}'/>
+		<input type="hidden" name="tag" value="{(isset($CURRENT_TAG)) ? $CURRENT_TAG : ''}" />
 		<input type="hidden" name="folder_id" value="{$FOLDER_ID}" />
 		<input type="hidden" name="folder_value" value="{$FOLDER_VALUE}" />
 		<input type="hidden" name="folder" value="{$VIEWNAME}" />
@@ -88,13 +88,13 @@
 										{assign var="DATA_TYPE" value=$LISTVIEW_HEADER['type']}
 										{if $DATA_TYPE == 'string'}
 											<div class="row-fluid">
-												<input type="text" name="{$LISTVIEW_HEADER_KEY}" class="listSearchContributor inputElement" value="{$SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['searchValue']}" data-fieldinfo='{$FIELD_INFO|escape}'/>
+												<input type="text" name="{$LISTVIEW_HEADER_KEY}" class="listSearchContributor inputElement" value="{(isset($SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['searchValue'])) ? $SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['searchValue'] : ''}" data-fieldinfo='{if isset($FIELD_INFO)}{$FIELD_INFO|escape}{/if}'/>
 											</div>
 										{elseif $DATA_TYPE == 'picklist'}
 											{assign var=PICKLIST_VALUES value=Reports_Field_Model::getPicklistValueByField($LISTVIEW_HEADER_KEY)}
-											{assign var=SEARCH_VALUES value=explode(',',$SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['searchValue'])}
+											{assign var=SEARCH_VALUES value=explode(',',(isset($SEARCH_INFO['searchValue'])) ? $SEARCH_INFO['searchValue'] : ',')}
 											<div class="row-fluid">
-												<select class="select2 listSearchContributor report-type-select" name="{$LISTVIEW_HEADER_KEY}" multiple data-fieldinfo='{$FIELD_INFO|escape}'>
+												<select class="select2 listSearchContributor report-type-select" name="{$LISTVIEW_HEADER_KEY}" multiple data-fieldinfo='{if isset($FIELD_INFO)}{$FIELD_INFO|escape}{/if}'>
 													{foreach item=PICKLIST_LABEL key=PICKLIST_KEY from=$PICKLIST_VALUES}
 														{if $PICKLIST_LABEL eq 'Chart'}
 															{assign var="ICON_CLASS" value='fa fa-pie-chart'}
@@ -106,7 +106,7 @@
 												</select>
 											</div>
 										{/if}
-										<input type="hidden" class="operatorValue" value="{$SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['comparator']}">
+										<input type="hidden" class="operatorValue" value="{(isset($SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['comparator'])) ? $SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['comparator'] : ''}">
 									</th>
 								{/foreach}
 							</tr>
@@ -125,7 +125,7 @@
 									<td class="listViewEntryValue" data-name="{$LISTVIEW_HEADERNAME}" title="{$LISTVIEW_ENTRY_RAWVALUE}" data-rawvalue="{$LISTVIEW_ENTRY_RAWVALUE}" data-field-type="">
 										<span class="fieldValue">
 											<span class="value textOverflowEllipsis">
-												{if $LISTVIEW_HEADERNAME eq 'reporttype'}
+												{if isset($LISTVIEW_HEADERNAME) && $LISTVIEW_HEADERNAME eq 'reporttype'}
 													{if $LISTVIEW_ENTRY_VALUE eq 'summary' || $LISTVIEW_ENTRY_VALUE eq 'tabular'}
 														<center title="{vtranslate('LBL_DETAIL_REPORT', $MODULE)}"><span class='vicon-detailreport' style="font-size:17px;"></span></center>
 													{elseif $LISTVIEW_ENTRY_VALUE eq 'chart'}
@@ -152,7 +152,7 @@
 									<div class="emptyRecordsDiv">
 										<div class="emptyRecordsContent">
 											{assign var=SINGLE_MODULE value="SINGLE_$MODULE"}
-											{vtranslate('LBL_NO')} {vtranslate($MODULE, $MODULE)} {vtranslate('LBL_FOUND')}.{if $IS_MODULE_EDITABLE} <a href="{$MODULE_MODEL->getCreateRecordUrl()}"> {vtranslate('LBL_CREATE')} </a> {if Users_Privileges_Model::isPermitted($MODULE, 'Import') && $LIST_VIEW_MODEL->isImportEnabled()} {vtranslate('LBL_OR', $MODULE)} <a style="color:blue" href="#" onclick="return Vtiger_Import_Js.triggerImportAction()"> {vtranslate('LBL_IMPORT', $MODULE)} </a>{vtranslate($MODULE, $MODULE)}{else}{vtranslate($SINGLE_MODULE, $MODULE)}{/if}{/if}
+											{vtranslate('LBL_NO')} {vtranslate($MODULE, $MODULE)} {vtranslate('LBL_FOUND')}.{if isset($IS_MODULE_EDITABLE) && $IS_MODULE_EDITABLE} <a href="{$MODULE_MODEL->getCreateRecordUrl()}"> {vtranslate('LBL_CREATE')} </a> {if Users_Privileges_Model::isPermitted($MODULE, 'Import') && $LIST_VIEW_MODEL->isImportEnabled()} {vtranslate('LBL_OR', $MODULE)} <a style="color:blue" href="#" onclick="return Vtiger_Import_Js.triggerImportAction()"> {vtranslate('LBL_IMPORT', $MODULE)} </a>{vtranslate($MODULE, $MODULE)}{else}{vtranslate($SINGLE_MODULE, $MODULE)}{/if}{/if}
 										</div>
 									</div>
 								</td>
diff --git a/layouts/v7/modules/Reports/ModuleHeader.tpl b/layouts/v7/modules/Reports/ModuleHeader.tpl
index 2e5d57fec1199b5113c82d548770016156968e15..37f5038fb011357b945b975577afc5818d078943 100644
--- a/layouts/v7/modules/Reports/ModuleHeader.tpl
+++ b/layouts/v7/modules/Reports/ModuleHeader.tpl
@@ -36,7 +36,7 @@
 						&nbsp;
 					</p>
 				</span>
-				{if $VIEWNAME}
+				{if isset($VIEWNAME) && $VIEWNAME}
 					{if $VIEWNAME neq 'All'}
 						{foreach item=FOLDER from=$FOLDERS}
 							{if $FOLDER->getId() eq $VIEWNAME}
@@ -48,13 +48,14 @@
 						{assign var=FOLDERNAME value=vtranslate('LBL_ALL_REPORTS', $MODULE)}
 					{/if}
 					<span>
-						<p class="current-filter-name filter-name pull-left"><span class="fa fa-angle-right" aria-hidden="true"></span>&nbsp;{$FOLDERNAME}&nbsp;</p>
+						<p class="current-filter-name filter-name pull-left"><span class="fa fa-angle-right" aria-hidden="true"></span>&nbsp;{if isset($FOLDERNAME)}{$FOLDERNAME}{else}''{/if}&nbsp;</p>
 					</span>
 				{/if}
 			</span>
 
 			<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,14 +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())}" 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>&nbsp; {vtranslate($childLink->getLabel(), $MODULE)}</a>
+										<li id="{$MODULE}_listView_basicAction_{Vtiger_Util_Helper::replaceSpaceWithUnderScores($childLink->getLabel())}" data-edition-disable="{if isset($childLink->disabled)} {$childLink->disabled} {/if}" 
+											data-edition-message="{if isset($childLink->message)} {$childLink->message} {/if}">
+											<a {if ($childLink) && !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>&nbsp; {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 75ccfee0568aa1cd5a50879638e3993ac7ab139e..637c32b3b7f0678f3dff9346eb9b77c6c19bcd34 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} />&nbsp;<span>{vtranslate('LBL_ASCENDING',$MODULE)}</span>&nbsp;&nbsp;
-                <input type="radio" name="{$ROW}" class="sortOrder" value="Descending" {if $SELECTED_SORT_FIELD_VALUE eq Descending} checked="" {/if}/>&nbsp;<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} />&nbsp;<span>{vtranslate('LBL_ASCENDING',$MODULE)}</span>&nbsp;&nbsp;
+                <input type="radio" name="{$ROW}" class="sortOrder" value="Descending" {if isset($SELECTED_SORT_FIELD_VALUE) && $SELECTED_SORT_FIELD_VALUE eq Descending} checked="" {/if}/>&nbsp;<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 a9e1c9172740307652955ff365d870a821980d26..ee93270cd17a69a36628a9d577dc877be3c5f489 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 d60695a0c3015664f520dd5150a29772ab475006..6544a025d45e18ef936e7943d3ac269c5c621cbe 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 f58aa9cf40b84c78d8828e4038a15aa53072305f..731a02ca7c29d24554f07af48472282b89d31a79 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%;">
@@ -51,14 +51,14 @@
                     <label class="col-lg-3 control-label textAlignLeft">{vtranslate('PRIMARY_MODULE',$MODULE)}<span class="redColor">*</span></label>
                     <div class="col-lg-4">
                         <select class="select2-container select2 col-lg-12 inputElement" id="primary_module" name="primary_module" data-rule-required="true"
-                                {if $RECORD_ID and $REPORT_MODEL->getPrimaryModule() and $IS_DUPLICATE neq true and $REPORT_TYPE eq "ChartEdit"} disabled="disabled"{/if}>
+                                {if $RECORD_ID and $REPORT_MODEL->getPrimaryModule() and isset($IS_DUPLICATE) && $IS_DUPLICATE neq true and $REPORT_TYPE eq "ChartEdit"} disabled="disabled"{/if}>
                             {foreach key=RELATED_MODULE_KEY item=RELATED_MODULE from=$MODULELIST}
                                 <option value="{$RELATED_MODULE_KEY}" {if $REPORT_MODEL->getPrimaryModule() eq $RELATED_MODULE_KEY } selected="selected" {/if}>
                                     {vtranslate($RELATED_MODULE_KEY,$RELATED_MODULE_KEY)}
                                 </option>
                             {/foreach}
                         </select>
-                        {if $RECORD_ID and $REPORT_MODEL->getPrimaryModule() and $IS_DUPLICATE neq true and $REPORT_TYPE eq "ChartEdit"}
+                        {if $RECORD_ID and $REPORT_MODEL->getPrimaryModule() and isset($IS_DUPLICATE) && $IS_DUPLICATE neq true and $REPORT_TYPE eq "ChartEdit"}
                             <input type="hidden" name="primary_module" value="{$REPORT_MODEL->getPrimaryModule()}" />
                         {/if}
                     </div>
@@ -68,7 +68,11 @@
                 <div class="form-group">
                     <label class="col-lg-3 control-label textAlignLeft">{vtranslate('LBL_SELECT_RELATED_MODULES',$MODULE)}&nbsp;({vtranslate('LBL_MAX',$MODULE)}&nbsp;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/chartReportHiddenContents.tpl b/layouts/v7/modules/Reports/chartReportHiddenContents.tpl
index 0e34d4f22aa4840fa882cead2cbe0b9b45628ef3..0b0f40ee86d0e89476838b2a7c9359e280acad79 100644
--- a/layouts/v7/modules/Reports/chartReportHiddenContents.tpl
+++ b/layouts/v7/modules/Reports/chartReportHiddenContents.tpl
@@ -32,11 +32,11 @@
             <optgroup label='{vtranslate($SECONDARY_MODULE_NAME,$MODULE)}-{vtranslate($BLOCK_LABEL,$SECONDARY_MODULE_NAME)}'>
                 {foreach key=FIELD_KEY item=FIELD_LABEL from=$BLOCK}
                     {assign var=FIELD_INFO value=explode(':', $FIELD_KEY)}
-                    {if $FIELD_INFO[4] eq 'D' or $FIELD_INFO[4] eq 'DT'}
+                    {if isset($FIELD_INFO[4]) && ($FIELD_INFO[4] eq 'D' or $FIELD_INFO[4] eq 'DT')}
                         <option value="{$FIELD_KEY}:Y">{vtranslate($SECONDARY_MODULE_NAME, $SECONDARY_MODULE_NAME)} {vtranslate($FIELD_LABEL, $SECONDARY_MODULE_NAME)} ({vtranslate('LBL_YEAR', $SECONDARY_MODULE_NAME)})</option>
                         <option value="{$FIELD_KEY}:MY">{vtranslate($SECONDARY_MODULE_NAME, $SECONDARY_MODULE_NAME)} {vtranslate($FIELD_LABEL, $SECONDARY_MODULE_NAME)} ({vtranslate('LBL_MONTH', $SECONDARY_MODULE_NAME)})</option>
                         <option value="{$FIELD_KEY}">{vtranslate($SECONDARY_MODULE_NAME, $SECONDARY_MODULE_NAME)} {vtranslate($FIELD_LABEL, $SECONDARY_MODULE_NAME)}</option>
-                    {else if $FIELD_INFO[4] neq 'I' and $FIELD_INFO[4] neq 'N' and $FIELD_INFO[4] neq 'NN'}
+                    {else if isset($FIELD_INFO[4]) && $FIELD_INFO[4] neq 'I' and $FIELD_INFO[4] neq 'N' and $FIELD_INFO[4] neq 'NN'}
                         <option value="{$FIELD_KEY}">{vtranslate($SECONDARY_MODULE_NAME, $SECONDARY_MODULE_NAME)} {vtranslate($FIELD_LABEL, $SECONDARY_MODULE_NAME)}</option>
                     {/if}
                 {/foreach}
diff --git a/layouts/v7/modules/Reports/step2.tpl b/layouts/v7/modules/Reports/step2.tpl
index 94935b08dbef8530173daa8c6dd252547a8ce715..6add2c6ee722c8c4be407ce923d435731d009bcd 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 3f287d2e00d44867729919f01b6b22d0c6f0e283..524a8e7912468569b744ff76d18d3f8706c36403 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/libraries/PHPExcel/PHPExcel/Shared/OLE.php b/libraries/PHPExcel/PHPExcel/Shared/OLE.php
index 3e0af0162cb2c64873fcf5291ffe90da158607bc..f52abfc47af39e5e4319a9db8a39d1a6e84097cf 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/OLE.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLE.php
@@ -486,12 +486,12 @@ class PHPExcel_Shared_OLE
 		$res = '';
 
 		for ($i = 0; $i < 4; ++$i) {
-			$hex = $low_part % 0x100;
+			$hex = ((int)$low_part) % 0x100;
 			$res .= pack('c', $hex);
 			$low_part /= 0x100;
 		}
 		for ($i = 0; $i < 4; ++$i) {
-			$hex = $high_part % 0x100;
+			$hex = ((int)$high_part) % 0x100;
 			$res .= pack('c', $hex);
 			$high_part /= 0x100;
 		}
diff --git a/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/Root.php b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/Root.php
index 9a214167294d3e542ce149a3e3dc54d2ebd61ca6..af8c8211b9c35fd2d5713af33937fbe5e5e79c1b 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/Root.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/Root.php
@@ -36,6 +36,10 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
 	 */
 	protected $_tmp_dir		= NULL;
 
+	protected $_tempDir = NULL;
+	protected $_BIG_BLOCK_SIZE = NULL;
+	protected $_SMALL_BLOCK_SIZE = NULL;
+	protected $_FILEH_ = false;
 	/**
 	 * @param integer $time_1st A timestamp
 	 * @param integer $time_2nd A timestamp
@@ -78,13 +82,13 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
 
 		if (is_resource($filename)) {
 		    $this->_FILEH_ = $filename;
-		} else if ($filename == '-' || $filename == '') {
-			if ($this->_tmp_dir === NULL)
-				$this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir();
-			$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
-			$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
-			if ($this->_FILEH_ == false) {
-				throw new Exception("Can't create temporary file.");
+		} else if ($filename == '-' || $filename == '') {
+			if ($this->_tmp_dir === NULL)
+				$this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir();
+			$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
+			$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
+			if ($this->_FILEH_ == false) {
+				throw new Exception("Can't create temporary file.");
 			}
 		} else {
 			$this->_FILEH_ = fopen($filename, "wb");
@@ -94,7 +98,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
 		}
 		// Make an array of PPS's (for Save)
 		$aList = array();
-		PHPExcel_Shared_OLE_PPS::_savePpsSetPnt($aList, array($this));
+		PHPExcel_Shared_OLE_PPS::_savePpsSetPnt($aList, array($this));
 		// calculate values for header
 		list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
 		// Save Header
diff --git a/libraries/PHPExcel/PHPExcel/WorksheetIterator.php b/libraries/PHPExcel/PHPExcel/WorksheetIterator.php
index b939b886d60905436008621182aa55c0a8194cbc..4df2e2afb204a0bff7a01d292a4113946af4e08e 100644
--- a/libraries/PHPExcel/PHPExcel/WorksheetIterator.php
+++ b/libraries/PHPExcel/PHPExcel/WorksheetIterator.php
@@ -71,6 +71,7 @@ class PHPExcel_WorksheetIterator implements Iterator
 	/**
 	 * Rewind iterator
 	 */
+    #[\ReturnTypeWillChange]
     public function rewind() {
         $this->_position = 0;
     }
@@ -80,6 +81,7 @@ class PHPExcel_WorksheetIterator implements Iterator
      *
      * @return PHPExcel_Worksheet
      */
+    #[\ReturnTypeWillChange]
     public function current() {
     	return $this->_subject->getSheet($this->_position);
     }
@@ -89,6 +91,7 @@ class PHPExcel_WorksheetIterator implements Iterator
      *
      * @return int
      */
+    #[\ReturnTypeWillChange]
     public function key() {
         return $this->_position;
     }
@@ -96,6 +99,7 @@ class PHPExcel_WorksheetIterator implements Iterator
     /**
      * Next value
      */
+    #[\ReturnTypeWillChange]
     public function next() {
         ++$this->_position;
     }
@@ -105,6 +109,7 @@ class PHPExcel_WorksheetIterator implements Iterator
      *
      * @return boolean
      */
+    #[\ReturnTypeWillChange]
     public function valid() {
         return $this->_position < $this->_subject->getSheetCount();
     }
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5.php
index 0a9cb5a8485783c59a003d68eb798686ade99492..5a5fd8655d69e19a7bed2514682e61989c6d5e8e 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5.php
@@ -104,6 +104,8 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
 	 * @var array
 	 */
 	private $_documentSummaryInformation;
+	private $_writerWorksheets;
+	private $_writerWorkbook;
 
 	/**
 	 * Create a new PHPExcel_Writer_Excel5
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php
index 18626254439a6a0ba30a1383a8f5bc033daed293..6833ffad83a5d0872899827faab6be1fa7b99528 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php
@@ -115,6 +115,9 @@ class PHPExcel_Writer_Excel5_Parser
 	 */
 	public $_references;
 
+	public $ptg;
+	public $_functions;
+
 	/**
 	 * The class constructor
 	 *
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php
index 0fff9c6f8a35c7ce73fef50497aec7592056549b..5d94acb13311471d3887cb2702c093f0f45749e4 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php
@@ -198,6 +198,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
 	 * @var array
 	 */
 	public $_fntHashIndex;
+	private $_preCalculateFormulas;
+	private $_print_headers;
 
 	/**
 	 * Constructor
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php
index 4c8c6fdab05ce96f9f327444e660966e61590a6a..af5a158346046ede87f3a14d12ddcbf65b4bcfb9 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php
@@ -131,6 +131,9 @@ class PHPExcel_Writer_Excel5_Xf
 	 */
 	public $_right_color;
 
+	public $_diag;
+	public $_diag_color;
+	public $_style;
 	/**
 	 * Constructor
 	 *
diff --git a/modules/Reports/ReportRun.php b/modules/Reports/ReportRun.php
index 960db89561c8006b47a2327ee4db8a1c518c9982..2488b29c53177ab261fea68dded81c3b73efe86a 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);
 		}
@@ -371,14 +374,18 @@ class ReportRun extends CRMEntity {
 		$ssql .= " order by vtiger_selectcolumn.columnindex";
 		$result = $adb->pquery($ssql, array($reportid));
 		$permitted_fields = Array();
-
+		$module = '';
         $selectedModuleFields = array();
         require('user_privileges/user_privileges_'.$current_user->id.'.php');
 		while ($columnslistrow = $adb->fetch_array($result)) {
 			$fieldname = "";
-			$fieldcolname = $columnslistrow["columnname"];
-			list($tablename, $colname, $module_field, $fieldname, $single) = explode(':', $fieldcolname);
-			list($module, $field) = explode('_', $module_field, 2);
+			$fieldcolname = isset($columnslistrow["columnname"]) ? $columnslistrow["columnname"] : '';
+			if ($fieldcolname != null && substr_count($fieldcolname, ':') >= 4) {
+				list($tablename, $colname, $module_field, $fieldname, $single) = explode(':', $fieldcolname);
+				if ($module_field != null && substr_count($module_field, '_') >= 1) {
+					list($module, $field) = explode('_', $module_field, 2);
+				}
+			}
             $selectedModuleFields[$module][] = $fieldname;
 			$inventory_fields = array('serviceid');
 			$inventory_modules = getInventoryModules();
@@ -402,9 +409,9 @@ class ReportRun extends CRMEntity {
 				$mod_strings = return_module_language($current_language, $module);
 			}
 
-			$targetTableName = $tablename;
+			$targetTableName = isset($tablename) ? $tablename : '';
 
-			$fieldlabel = trim(preg_replace("/$module/", " ", $selectedfields[2], 1));
+			$fieldlabel = trim(preg_replace("/$module/", " ", isset($selectedfields[2]) ? $selectedfields[2] :'', 1));
 			$mod_arr = explode('_', $fieldlabel);
 			$fieldlabel = trim(str_replace("_", " ", $fieldlabel));
 			//modified code to support i18n issue
@@ -426,7 +433,7 @@ class ReportRun extends CRMEntity {
 				$this->queryPlanner->addTable($selectedfields[0]);
 				continue;
 			} 
-			if ((CheckFieldPermission($fieldname, $mod) != 'true' && $colname != "crmid" && (!in_array($fieldname, $inventory_fields) && in_array($module, $inventory_modules))) || empty($fieldname)) {
+			if ((CheckFieldPermission($fieldname, $mod) != 'true' && isset($colname) && $colname != "crmid" && (!in_array($fieldname, $inventory_fields) && in_array($module, $inventory_modules))) || empty($fieldname)) {
 				continue;
 			} else {
 				$this->labelMapping[$selectedfields[2]] = str_replace(" ", "_", $fieldlabel);
@@ -454,7 +461,7 @@ class ReportRun extends CRMEntity {
 			if ($this->secondarymodule) {
 				$secondaryModules = explode(':', $this->secondarymodule);
 				foreach ($secondaryModules as $secondaryModule) {
-                    $columnsSelected = (array)$selectedModuleFields[$secondaryModule];
+                    $columnsSelected = isset($selectedModuleFields[$secondaryModule]) ? (array)$selectedModuleFields[$secondaryModule] : [];
 					$moduleModel = Vtiger_Module_Model::getInstance($secondaryModule);
                     /**
                      * To check whether any column is selected from secondary module. If so, then only add 
@@ -732,21 +739,23 @@ 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];
-		$fieldName = $selectedfields[3];
-		list($moduleName, $fieldLabel) = explode('_', $moduleFieldLabel, 2);
-		$fieldInfo = getFieldByReportLabel($moduleName, $fieldLabel);
+		$columnName = isset($selectedfields[1]) ? $selectedfields[1] : '';
+		$moduleFieldLabel = isset($selectedfields[2]) ? $selectedfields[2] : '';
+		$fieldName = isset($selectedfields[3]) ? $selectedfields[3] : '';
+		if ($moduleFieldLabel !=null && substr_count($moduleFieldLabel, '_') >= 1) {
+			list($moduleName, $fieldLabel) = explode('_', $moduleFieldLabel, 2);
+			$fieldInfo = getFieldByReportLabel($moduleName, $fieldLabel);
+		}
 
-		if ($moduleName == 'ModComments' && $fieldName == 'creator') {
+		if (isset($moduleName) && $moduleName == 'ModComments' && $fieldName == 'creator') {
 			$concatSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_usersModComments.first_name',
 				'last_name' => 'vtiger_usersModComments.last_name'), 'Users');
 			$queryColumn = "trim(case when (vtiger_usersModComments.user_name not like '' and vtiger_crmentity.crmid!='') then $concatSql end) AS ModComments_Creator";
 			$this->queryPlanner->addTable('vtiger_usersModComments');
 			$this->queryPlanner->addTable("vtiger_usersModComments");
-		} elseif ((($fieldInfo['uitype'] == '10' || isReferenceUIType($fieldInfo['uitype'])) && $fieldInfo['tablename'] != 'vtiger_inventoryproductrel') && $fieldInfo['uitype'] != '52' && $fieldInfo['uitype'] != '53') {
+		} elseif (isset($fieldInfo) && (($fieldInfo['uitype'] == '10' || isReferenceUIType($fieldInfo['uitype'])) && $fieldInfo['tablename'] != 'vtiger_inventoryproductrel') && $fieldInfo['uitype'] != '52' && $fieldInfo['uitype'] != '53') {
 			$fieldSqlColumns = $this->getReferenceFieldColumnList($moduleName, $fieldInfo);
 			if (php7_count($fieldSqlColumns) > 0) {
 				$queryColumn = "(CASE WHEN $tableName.$columnName NOT LIKE '' THEN (CASE";
@@ -2209,6 +2218,7 @@ class ReportRun extends CRMEntity {
 	 */
 	function getReportsQuery($module, $type = '') {
 		global $log, $current_user, $adb;
+		$query = '';
 		$secondary_module = "'";
 		$secondary_module .= str_replace(":", "','", $this->secondarymodule);
 		$secondary_module .="'";
@@ -2999,7 +3009,7 @@ class ReportRun extends CRMEntity {
 		$allColumnsRestricted = false;
 
 		if ($type == 'COLUMNSTOTOTAL') {
-			if ($columnstotalsql != '') {
+			if (isset($columnstotalsql) && $columnstotalsql != '') {
 				$reportquery = "select " . $columnstotalsql . " " . $reportquery . " " . $wheresql;
 			}
 		} else {
@@ -3077,7 +3087,10 @@ class ReportRun extends CRMEntity {
 		static $mod_query_details = array();
 		
 		require('user_privileges/user_privileges_' . $current_user->id . '.php');
+		$coltotalhtml = '';
 		$modules_selected = array();
+		$picklistarray = array();
+		static $mod_query_details = array();
 		$modules_selected[] = $this->primarymodule;
 		if (!empty($this->secondarymodule)) {
 			$sec_modules = explode(':', $this->secondarymodule);
@@ -3153,6 +3166,7 @@ class ReportRun extends CRMEntity {
 				}
 				do {
 					$arraylists = Array();
+					$sec_modules = array();
 					for ($i = 0; $i < $y; $i++) {
 						$fld = $fieldsList[$i]['field'];
 						$headerLabel = $fieldsList[$i]['headerlabel'];
@@ -3916,18 +3930,20 @@ class ReportRun extends CRMEntity {
 			return $coltotalhtml;
 		} elseif ($outputformat == "PRINT") {
 			$reportData = $this->GenerateReport('PDF', $filtersql);
+			$header = '';
 			if (is_array($reportData) && $reportData['count'] > 0) {
 				$data = $reportData['data'];
 				$noofrows = $reportData['count'];
 				$firstRow = reset($data);
 				$headers = array_keys($firstRow);
 				foreach ($headers as $headerName) {
-					if ($headerName == 'ACTION' || $headerName == vtranslate('LBL_ACTION', $this->primarymodule) || $headerName == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL_ACTION', $this->primarymodule) || $headerName == vtranslate('LBL ACTION', $this->primarymodule) || $key == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL ACTION', $this->primarymodule)) {
+					if ($headerName == 'ACTION' || $headerName == vtranslate('LBL_ACTION', $this->primarymodule) || $headerName == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL_ACTION', $this->primarymodule) || $headerName == vtranslate('LBL ACTION', $this->primarymodule) || isset($key) && $key == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL ACTION', $this->primarymodule)) {
 						continue;
 					}
 					$header .= '<th>' . $headerName . '</th>';
 				}
 				$groupslist = $this->getGroupingList($this->reportid);
+				$groupByFieldNames = array();
 				foreach ($groupslist as $reportFieldName => $reportFieldValue) {
 					$nameParts = explode(":", $reportFieldName);
 					list($groupFieldModuleName, $groupFieldName) = explode('_', $nameParts[2], 2);
@@ -3995,7 +4011,7 @@ class ReportRun extends CRMEntity {
 					}
 				} else {
 					foreach ($data as $key => $values) {
-						$valtemplate .= '<tr>';
+						$valtemplate = '<tr>';
 						foreach ($values as $fieldName => $value) {
 							if ($fieldName == 'ACTION' || $fieldName == vtranslate('LBL_ACTION', $this->primarymodule) || $fieldName == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL_ACTION', $this->primarymodule) || $fieldName == vtranslate('LBL ACTION', $this->primarymodule) || $fieldName == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL ACTION', $this->primarymodule)) {
 								continue;
@@ -4244,10 +4260,11 @@ class ReportRun extends CRMEntity {
 			}
 		}
 		// Save the information
-		$this->_columnstotallist = $stdfilterlist;
-
-		$log->info("ReportRun :: Successfully returned getColumnsTotal" . $reportid);
-		return $stdfilterlist;
+		if (isset($stdfilterlist)) {
+			$this->_columnstotallist = $stdfilterlist;
+			$log->info("ReportRun :: Successfully returned getColumnsTotal" . $reportid);
+			return $stdfilterlist;
+		}
 	}
 
 	//<<<<<<new>>>>>>>>>
@@ -4563,7 +4580,7 @@ class ReportRun extends CRMEntity {
 		$worksheet = $workbook->setActiveSheetIndex(0);
 
 		$reportData = $this->GenerateReport("PDF", $filterlist, false, false, false, 'ExcelExport');
-		$arr_val = $reportData['data'];
+		$arr_val = isset($reportData['data']) ? $reportData['data'] : array();
 		$totalxls = $this->GenerateReport("XLS", $filterlist, false, false, false, 'ExcelExport');
 		$numericTypes = array('currency', 'double', 'integer', 'percentage');
 
@@ -4576,7 +4593,7 @@ class ReportRun extends CRMEntity {
 			$count = 0;
 			$rowcount = 1;
 			//copy the first value details
-			$arrayFirstRowValues = $arr_val[0];
+			$arrayFirstRowValues = isset($arr_val[0]) ? $arr_val[0] : array();
 			foreach ($arrayFirstRowValues as $key => $value) {
 				// It'll not translate properly if you don't mention module of that string
 				if ($key == 'ACTION' || $key == vtranslate('LBL_ACTION', $this->primarymodule) || $key == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL_ACTION', $this->primarymodule) || $key == vtranslate('LBL ACTION', $this->primarymodule) || $key == vtranslate($this->primarymodule, $this->primarymodule) . " " . vtranslate('LBL ACTION', $this->primarymodule)) {
@@ -4619,7 +4636,7 @@ class ReportRun extends CRMEntity {
 			// Summary Total
 			$rowcount++;
 			$count = 0;
-			if (is_array($totalxls[0])) {
+			if (isset($totalxls[0]) && is_array($totalxls[0])) {
 				foreach ($totalxls[0] as $key => $value) {
 					$exploedKey = explode('_', $key);
 					$chdr = end($exploedKey);
@@ -4662,7 +4679,7 @@ class ReportRun extends CRMEntity {
 		$mod_strings = return_module_language($current_language, $currentModule);
 
 		$reportData = $this->GenerateReport("PDF", $filterlist);
-		$arr_val = $reportData['data'];
+		$arr_val = isset($reportData['data']) ? $reportData['data'] : '';
 
 		$fp = fopen($fileName, 'w+');
 
@@ -4735,7 +4752,7 @@ class ReportRun extends CRMEntity {
 		if ($this->_groupbycondition !== false) {
 			return $this->_groupbycondition;
 		}
-        
+        $groupByCondition = array();
 		$groupByTimeQuery = "SELECT * FROM vtiger_reportgroupbycolumn WHERE reportid=?";
 		$groupByTimeRes = $adb->pquery($groupByTimeQuery, array($reportId));
 		$num_rows = $adb->num_rows($groupByTimeRes);
diff --git a/modules/Reports/ReportUtils.php b/modules/Reports/ReportUtils.php
index d0a18bd77e74f20f075e3ef46aac479843a9486d..9fbda724d97051126675f8118211fb092b132d25 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 ff44a351e434f99ede1af371bc66d749f3c9ef96..1dd9f3e39f4da618a735094eac741540132a70ef 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 != "")
             {
@@ -464,6 +465,8 @@ class Reports extends CRMEntity{
 		global $log;
 		global $mod_strings,$current_user;
 		$returndata = Array();
+		$current_user_parent_role_seq = '';
+		$is_admin = false;
 		
 		require_once('include/utils/UserInfoUtil.php');
 
@@ -582,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;
@@ -611,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)) {
@@ -682,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);
@@ -694,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];
 	}
@@ -805,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 b1c5ab0b9529bc79092858598144cfb886c7e7cd..70d178f883fa17391515ed77b2f0e729d7b5114a 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 7e203c46a86b480294d58d6d507ebbbe99c1f96d..27c4a04b9bc205cfceaa37dc279b8c2cb70d1c69 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/Chart.php b/modules/Reports/models/Chart.php
index 62ae4124b65e2221dce81f92b5c87451ef53c48f..885be84e6b8e18c76ff2611520121de0f4a6811d 100644
--- a/modules/Reports/models/Chart.php
+++ b/modules/Reports/models/Chart.php
@@ -121,7 +121,9 @@ abstract class Base_Chart extends Vtiger_Base_Model{
 	}
 
 	function getQueryColumnsByFieldModel() {
-		return $this->fieldModels;
+		if (property_exists($this, 'fieldModels')) {
+			return $this->fieldModels;
+		}
 	}
 
 	function setQueryColumns($columns) {
@@ -168,7 +170,7 @@ abstract class Base_Chart extends Vtiger_Base_Model{
 				}
 			}
 		}
-		if($fieldModels) $this->fieldModels = $fieldModels;
+		if(isset($fieldModels) && $fieldModels) $this->fieldModels = $fieldModels;
 	}
 
 	function setGroupByColumns($columns) {
@@ -496,7 +498,8 @@ class PieChart extends Base_Chart {
 	function generateData(){
 		$db = PearDatabase::getInstance();
 		$values = array();
-
+		$labels = array();
+		$links = array();
 		$chartSQL = $this->getQuery();
 		$result = $db->pquery($chartSQL, array());
 		$rows = $db->num_rows($result);
diff --git a/modules/Reports/models/Field.php b/modules/Reports/models/Field.php
index c5e21c134df59f77c6048924c9074ff261c18e01..57f9a7e6e7a010dd39a5195e6daeddf98a6266db 100644
--- a/modules/Reports/models/Field.php
+++ b/modules/Reports/models/Field.php
@@ -11,7 +11,7 @@
 class Reports_Field_Model extends Vtiger_Field_Model {
 
 	static function getPicklistValueByField($fieldName) {
-		$picklistValues = false;
+		$picklistValues = array();
 		if ($fieldName == 'reporttype') {
 			$picklistValues = array(
 				'tabular'	=> vtranslate('tabular', 'Reports'),
diff --git a/modules/Reports/models/Folder.php b/modules/Reports/models/Folder.php
index 896abdab5f8804bfb5df07179b98126cd295ec4d..9075ed0324b9ab44f36ca4a0c4f817a141895b92 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 b35ea0b0957cb468f39421b22818c8d2669a37aa..4fc3eee22761e0e0b9355f71482a3ae1a42e9555 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 a88e21a9527e5d7644d92938668b6f1239f85055..ed474d0a3a66be2e59528c866b60a6742ce29d2e 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;
@@ -654,7 +654,7 @@ class Reports_Record_Model extends Vtiger_Record_Model {
 				if(!is_array($groupInfo)) continue;
 
 				$groupColumns = $groupInfo['columns'];
-				$groupCondition = $groupInfo['condition'];
+				$groupCondition = isset($groupInfo['condition']) ? $groupInfo['condition'] : '';
 
 				foreach($groupColumns as $columnIndex => $columnCondition) {
 					if(empty($columnCondition)) continue;
@@ -727,7 +727,7 @@ class Reports_Record_Model extends Vtiger_Record_Model {
 					$advancedFilter[$groupIndex]["conditionexpression"] = $groupConditionExpression;
 				}
 
-				$groupConditionExpression = $advancedFilter[$groupIndex]["conditionexpression"];
+				$groupConditionExpression = isset($advancedFilter[$groupIndex]["conditionexpression"]) ? $advancedFilter[$groupIndex]["conditionexpression"] : '';
 				if(empty($groupConditionExpression)) continue; // Case when the group doesn't have any column criteria
 
 				$db->pquery("INSERT INTO vtiger_relcriteria_grouping(groupid, queryid, group_condition, condition_expression) VALUES (?,?,?,?)",
@@ -1080,7 +1080,7 @@ class Reports_Record_Model extends Vtiger_Record_Model {
 			foreach($advancedFilter as $groupIndex => $groupInfo) {
                             if(!is_array($groupInfo)) continue;
 				$groupColumns = $groupInfo['columns'];
-				$groupCondition = $groupInfo['condition'];
+				$groupCondition = isset($groupInfo['condition']) ? $groupInfo['condition'] : '';
 
 				if (empty ($groupColumns)) {
 					unset($advancedFilter[1]['condition']);
diff --git a/modules/Reports/models/RecordStructure.php b/modules/Reports/models/RecordStructure.php
index f40d13f5364899c9accfe590264ff15497eb8217..5b747c1d0599c8ae4c73b0faaa619dd49baced72 100644
--- a/modules/Reports/models/RecordStructure.php
+++ b/modules/Reports/models/RecordStructure.php
@@ -19,6 +19,7 @@ class Reports_RecordStructure_Model extends Vtiger_RecordStructure_Model {
 	 * @return <array> - values in structure array('block'=>array(fieldinfo));
 	 */
 	public function getStructure() {
+		$eventCustomFields = array();
             list($moduleName) = func_get_args();
 		if (!empty($this->structuredValues[$moduleName])) {
 			return $this->structuredValues[$moduleName];
@@ -80,6 +81,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 4ab553e9291aa19d144cec59c838c04e24f81b0a..2fafe65d44c4ed13fc90dd66c79f57720c82d2ef 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/ChartDetail.php b/modules/Reports/views/ChartDetail.php
index 520982f222fc6f6b4bf280c87aef0d30cd46dc78..dfc7fd2701ccfc1ad11ea5eab0723e307181d433 100644
--- a/modules/Reports/views/ChartDetail.php
+++ b/modules/Reports/views/ChartDetail.php
@@ -139,10 +139,14 @@ class Reports_ChartDetail_View extends Vtiger_Index_View {
 		}
 
 		$isPercentExist = false;
+		$relModuleName = '';
+		$fieldName = '';
 		$selectedDataFields = $reportChartModel->get('datafields');
 		foreach ($selectedDataFields as $dataField) {
-			list($tableName, $columnName, $moduleField, $fieldName, $single) = explode(':', $dataField);
-			list($relModuleName, $fieldLabel) = explode('_', $moduleField);
+			if (isset($dataField) && substr_count($dataField, ':') >= 4) {
+				list($tableName, $columnName, $moduleField, $fieldName, $single) = explode(':', $dataField);
+				list($relModuleName, $fieldLabel) = explode('_', $moduleField);
+			} 
 			$relModuleModel = Vtiger_Module_Model::getInstance($relModuleName);
 			$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $relModuleModel);
 			if ($fieldModel && $fieldModel->getFieldDataType() != 'currency') {
diff --git a/modules/Reports/views/Detail.php b/modules/Reports/views/Detail.php
index 22c0b28e3203d33432bacee1f617f825f9d87c96..70236740307d314a877de5cab11138c271f76655 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'];
@@ -138,7 +138,9 @@ class Reports_Detail_View extends Vtiger_Index_View {
 		foreach($dateFilters as $comparatorKey => $comparatorInfo) {
 			$comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
 			$comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
-			$comparatorInfo['label'] = vtranslate($comparatorInfo['label'],$module);
+			if (isset($module)) {
+				$comparatorInfo['label'] = vtranslate($comparatorInfo['label'],$module);
+			}
 			$dateFilters[$comparatorKey] = $comparatorInfo;
 		}
 		$viewer->assign('DATE_FILTERS', $dateFilters);
@@ -182,7 +184,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 f90d9814f27a8d056d81f78689ad82459f904700..d1cf79739f939ced7b7bac6ec49bf6ddff71869c 100644
--- a/modules/Reports/views/Edit.php
+++ b/modules/Reports/views/Edit.php
@@ -140,6 +140,7 @@ Class Reports_Edit_View extends Vtiger_Edit_View {
 		$viewer = $this->getViewer($request);
 		$moduleName = $request->getModule();
 		$record = $request->get('record');
+		$secondaryModuleFields = '';
 
 		$reportModel = Reports_Record_Model::getCleanInstance($record);
 		if(!empty($record)) {
@@ -198,7 +199,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]);
diff --git a/modules/Reports/views/List.php b/modules/Reports/views/List.php
index 9d4a01e02d16cc21c1f93e20f3ac5956b6b621fc..68587d8d6b7ad82badc4e38893496cf9fe326b74 100644
--- a/modules/Reports/views/List.php
+++ b/modules/Reports/views/List.php
@@ -120,7 +120,7 @@ class Reports_List_View extends Vtiger_Index_View {
 		$orderBy = $request->get('orderby');
 		$sortOrder = $request->get('sortorder');
 		$searchParams = $request->get('search_params');
-		$searchParams = $searchParams[0];
+		$searchParams = isset($searchParams[0]) ? $searchParams[0] : '';
 
 		$orderParams = Vtiger_ListView_Model::getSortParamsSession($moduleName.'_'.$folderId);
 		if($request->get('mode') == 'removeSorting') {
@@ -170,7 +170,7 @@ class Reports_List_View extends Vtiger_Index_View {
 
 		$viewer->assign('MODULE', $moduleName);
 		  // preProcess is already loading this, we can reuse
-		if(!$this->pagingModel){
+		if(!property_exists($this, 'pagingModel') || !$this->pagingModel){
 			$pagingModel = new Vtiger_Paging_Model();
 			$pagingModel->set('page', $pageNumber);
 		} else{
@@ -203,7 +203,7 @@ class Reports_List_View extends Vtiger_Index_View {
 		$viewer->assign('SEARCH_DETAILS', array());
 		$viewer->assign('LISTVIEW_MODEL',$listViewModel);
 		$viewer->assign('PAGING_MODEL', $pagingModel);
-		if(!$this->pagingModel){
+		if(!property_exists($this, 'pagingModel') || !$this->pagingModel){
 			$this->pagingModel = $pagingModel;
 		}
 
diff --git a/modules/Reports/views/SaveAjax.php b/modules/Reports/views/SaveAjax.php
index 62efc0eb7bb5b92d9b2e9653208824222b39b5ea..e1308fed8b5c0181341dda347460a5d9bdbd7a41 100644
--- a/modules/Reports/views/SaveAjax.php
+++ b/modules/Reports/views/SaveAjax.php
@@ -36,7 +36,7 @@ class Reports_SaveAjax_View extends Vtiger_IndexAjax_View {
 		if ($mode === 'save') {
 			$reportModel->saveAdvancedFilters();
 			$reportData = $reportModel->getReportData($pagingModel);
-			$data = $reportData['data'];
+			$data = isset($reportData['data']) ? $reportData['data'] : '';
 		} else if ($mode === 'generate') {
 			$reportData = $reportModel->generateData($pagingModel);
 			$data = $reportData['data'];