diff --git a/modules/Vtiger/models/Module.php b/modules/Vtiger/models/Module.php
index 9598039732ee8161ad674c9c10c2c39f20d518c0..a009600de8d880c361384a5f59fcf717fe082ae1 100644
--- a/modules/Vtiger/models/Module.php
+++ b/modules/Vtiger/models/Module.php
@@ -526,10 +526,11 @@ class Vtiger_Module_Model extends Vtiger_Module {
 			$query = "SELECT fieldname, tablename, entityidfield FROM vtiger_entityname WHERE tabid = ?";
 			$result = $adb->pquery($query, array($this->getId()));
 			$this->nameFields = array();
+			$fieldNames = '';
 			if($result){
 				$rowCount = $adb->num_rows($result);
 				if($rowCount > 0){
-					$fieldNames = $adb->query_result($result,0,'fieldname');
+					$fieldNames .= $adb->query_result($result,0,'fieldname');
 					$this->nameFields = explode(',', $fieldNames);
 				}
 			}
diff --git a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/GridViewContents.tpl b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/GridViewContents.tpl
index d96e8b8be165f9c81b484c94beaaa47b57c42d94..53d14e7c143d1d9e93ad56471b3211a9ee5c910b 100644
--- a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/GridViewContents.tpl
+++ b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/GridViewContents.tpl
@@ -22,12 +22,12 @@
 	<input type='hidden' name="pageNumber" value="{$PAGE_NUMBER}" id='pageNumber'>
 	<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="currentSearchParams" value="{(isset($SEARCH_DETAILS)) ? Vtiger_Util_Helper::toSafeHTML(Zend_JSON::encode($SEARCH_DETAILS)) : ''}" id="currentSearchParams" />
+	<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="viewType" value="{$VIEWTYPE}" />
diff --git a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/IndexViewPreProcess.tpl b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/IndexViewPreProcess.tpl
index a8f2acaaf35d49219fa1f24fda9667fe8f605588..6eb3356785872b9ba8f7053201becf0b921aaed4 100644
--- a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/IndexViewPreProcess.tpl
+++ b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/IndexViewPreProcess.tpl
@@ -12,7 +12,7 @@
     <div class="row">
         {include file="modules/Settings/Vtiger/SidebarHeader.tpl"}
         {assign var=ACTIVE_BLOCK value=['block' => 'Templates',
-                                        'menu' => $smary.request.module]}
+                                        'menu' => $REQ->get('module')]}
         {include file="modules/Settings/Vtiger/ModuleHeader.tpl"}
     </div>
 </div>
diff --git a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ListViewActions.tpl b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ListViewActions.tpl
index 2e7e20b8ee1ff1ea516414e86600d20ff85850e1..51df37b3accfe8f64e747f169f1771f527779738 100644
--- a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ListViewActions.tpl
+++ b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ListViewActions.tpl
@@ -30,7 +30,7 @@
                     <button type="button" class="btn btn-default viewType" title="{vtranslate('LBL_THUMBNAIL_VIEW',$MODULE)}" data-mode="grid" {if $VIEWTYPE eq 'grid'} disabled="disabled" {/if}><i class="fa fa-th-large"></i></button>
                 </div>
                 <div class="btn-group">
-                {if $editAction}
+                {if isset($editAction) && $editAction}
                     <button type="button" class="btn btn-default" id={$MODULE}_listView_massAction_{$editAction->getLabel()} 
                             {if stripos($editAction->getUrl(), 'javascript:')===0} href="javascript:void(0);" onclick='{$editAction->getUrl()|substr:strlen("javascript:")}'{else} href='{$editAction->getUrl()}' {/if} title="{vtranslate('LBL_EDIT', $MODULE)}">
                         <i class="fa fa-pencil"></i>
@@ -42,7 +42,7 @@
                         <i class="fa fa-trash"></i>
                     </button>
                 {/if}
-                {if $commentAction}
+                {if isset($commentAction) && $commentAction}
                     <button type="button" class="btn btn-default" id="{$MODULE}_listView_massAction_{$commentAction->getLabel()}" 
                             onclick="Vtiger_List_Js.triggerMassAction('{$commentAction->getUrl()}')" title="{vtranslate('LBL_COMMENT', $MODULE)}">
                         <i class="fa fa-comment"></i>
diff --git a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ModuleHeader.tpl b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ModuleHeader.tpl
index aeff72a75a4386474580adb9d9158fb716591113..e21fae9aa80a5cb4bb844b66cc14838f7d992612 100644
--- a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ModuleHeader.tpl
+++ b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/ModuleHeader.tpl
@@ -24,7 +24,7 @@
 					{if $REQ->get('view') eq 'Detail'}
 						<a title="{$RECORD->get('templatename')}">&nbsp;{$RECORD->get('templatename')}&nbsp;</a>
 					{/if}
-					{if $RECORD and $REQ->get('view') eq 'Edit'}
+					{if isset($RECORD) and $REQ->get('view') eq 'Edit'}
 						<a title="{$RECORD->get('templatename')}">&nbsp;{vtranslate('LBL_EDITING', $MODULE)} : {$RECORD->get('templatename')} &nbsp;</a>
 					{else if $REQ->get('view') eq 'Edit'}
 						<a>&nbsp;{vtranslate('LBL_ADDING_NEW', $MODULE)}&nbsp;</a>
diff --git a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/actions/MassDelete.php b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/actions/MassDelete.php
index 74c11f5b9c4ea0e2e6a0e4412ff28129a5a68473..0dbd8a0c0c645ff78a6b88e2313dfdc7128e7136 100644
--- a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/actions/MassDelete.php
+++ b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/actions/MassDelete.php
@@ -33,7 +33,7 @@ class EmailTemplates_MassDelete_Action extends Vtiger_Mass_Action {
 
 	public function process(Vtiger_Request $request) {
 		$moduleName = $request->getModule();
-
+		$systemTemplate = false;
 		$recordModel = new EmailTemplates_Record_Model();
 		$recordModel->setModule($moduleName);
 		$selectedIds = $request->get('selected_ids');
diff --git a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/models/ListView.php b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/models/ListView.php
index 066d7c05873dd392d03492b26dd244cbb7c89555..1b572e6ac0deceba199689a65f949bfce76b7fd6 100644
--- a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/models/ListView.php
+++ b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/models/ListView.php
@@ -212,7 +212,7 @@ class EmailTemplates_ListView_Model extends Vtiger_ListView_Model {
 		$searchKey = $this->getForSql('search_key');
 		$searchValue = $this->get('search_value');
 
-		$whereQuery .= " WHERE ";
+		$whereQuery = " WHERE ";
         $params = array();
 		if(!empty($searchKey) && !empty($searchValue)) {
 			$whereQuery .= "$searchKey LIKE ? AND ";
diff --git a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Detail.php b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Detail.php
index 120633386fd40f2928275360709455afd4455702..992bab953ae560179580367e8d6a937394a3796d 100644
--- a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Detail.php
+++ b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Detail.php
@@ -28,7 +28,7 @@ class EmailTemplates_Detail_View extends Vtiger_Index_View {
 
 		$recordId = $request->get('record');
 		$moduleName = $request->getModule();
-		if(!$this->record){
+		if(!property_exists($this, 'record') || !$this->record){
 			$this->record = EmailTemplates_DetailView_Model::getInstance($moduleName, $recordId);
 		}
 		$recordModel = $this->record->getRecord();
diff --git a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Edit.php b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Edit.php
index abc14a7e52168a08bf17c5429f99510d9e96ee9f..cbcb8a61cb5878cbbb5c605a0e822063699cd06e 100644
--- a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Edit.php
+++ b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/Edit.php
@@ -100,7 +100,7 @@ Class EmailTemplates_Edit_View extends Vtiger_Index_View {
 			$recordModel->set('body', '');
 		}
 		$recordModel->setModule('EmailTemplates');
-		if (!$this->record) {
+		if (!property_exists($this, 'record') || !$this->record) {
 			//Default templates will be having {$site_URL} keyword 
 			//so replacing keyword with value
 			$body = $recordModel->get('body');
diff --git a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/List.php b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/List.php
index caa1b09bf14d72c4fa605c205d052e8d08fce069..6563e83b409375306220b8ff845016e8d66e4fc5 100644
--- a/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/List.php
+++ b/pkg/vtiger/modules/EmailTemplates/modules/EmailTemplates/views/List.php
@@ -67,7 +67,7 @@ class EmailTemplates_List_View extends Vtiger_Index_View {
 		$orderParams = Vtiger_ListView_Model::getSortParamsSession($moduleName);
 		// TODO : need to remove this when vtiger6 is removed
 		$defaultLayout = Vtiger_Viewer::getDefaultLayoutName();
-		if($orderParams['viewType'] == 'grid' && $defaultLayout == 'v7'){
+		if(isset($orderParams['viewType']) && $orderParams['viewType'] == 'grid' && $defaultLayout == 'v7'){
 			$viewer->view('GridViewContents.tpl',$moduleName);
 		} else {
 			$viewer->view('ListViewContents.tpl', $moduleName);
@@ -149,7 +149,7 @@ class EmailTemplates_List_View extends Vtiger_Index_View {
 		$linkModels = $listViewModel->getListViewMassActions($linkParams);
 
 		// 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 {
@@ -182,14 +182,14 @@ class EmailTemplates_List_View extends Vtiger_Index_View {
 
 		$listViewModel->set('viewType',$viewType);
 
-		if (!$this->listViewHeaders) {
+		if (!property_exists($this, 'listViewHeaders') || !$this->listViewHeaders) {
 			$this->listViewHeaders = $listViewModel->getListViewHeaders();
 		}
-		if (!$this->listViewEntries) {
+		if (!property_exists($this, 'listViewEntries') || !$this->listViewEntries) {
 			$this->listViewEntries = $listViewModel->getListViewEntries($pagingModel);
 		}
 
-		if (!$this->pagingModel) {
+		if (!property_exists($this, 'pagingModel') || !$this->pagingModel) {
 			$this->pagingModel = $pagingModel;
 		}
 
@@ -197,7 +197,7 @@ class EmailTemplates_List_View extends Vtiger_Index_View {
 		$viewer->assign('VIEWID', $cvId);
 		$viewer->assign('MODULE', $moduleName);
 
-		if (!$this->listViewLinks) {
+		if (!property_exists($this, 'listViewLinks') || !$this->listViewLinks) {
 			$this->listViewLinks = $listViewModel->getListViewLinks($linkParams);
 		}
 		$viewer->assign('LISTVIEW_LINKS', $this->listViewLinks);