From 8f8f60c6da7b22c84906a31b827b17a88eaf4169 Mon Sep 17 00:00:00 2001
From: Prasad <prasad@vtiger.com>
Date: Fri, 12 Jul 2024 09:29:25 +0530
Subject: [PATCH] E_ALL - minor corrections to isset usage

---
 data/CRMEntity.php                            |  2 +-
 include/utils/EditViewUtils.php               |  4 ++--
 layouts/v7/modules/Documents/ModuleHeader.tpl |  2 +-
 .../Documents/partials/SidebarEssentials.tpl  |  2 +-
 .../Events/partials/EditViewContents.tpl      |  4 ++--
 .../modules/Events/uitypes/Multireference.tpl |  2 +-
 .../Inventory/partials/LineItemsContent.tpl   | 14 ++++++------
 .../Inventory/partials/LineItemsEdit.tpl      |  8 +++----
 layouts/v7/modules/Vtiger/AddCommentForm.tpl  |  2 +-
 layouts/v7/modules/Vtiger/ListViewActions.tpl |  2 +-
 .../v7/modules/Vtiger/ListViewContents.tpl    |  2 +-
 layouts/v7/modules/Vtiger/PopupContents.tpl   |  2 +-
 layouts/v7/modules/Vtiger/PopupNavigation.tpl |  4 ++--
 layouts/v7/modules/Vtiger/uitypes/Date.tpl    |  2 +-
 layouts/v7/modules/Vtiger/uitypes/Text.tpl    |  2 +-
 modules/Campaigns/Campaigns.php               |  1 +
 modules/CustomView/models/Record.php          |  2 +-
 modules/Documents/views/QuickCreateAjax.php   |  2 +-
 modules/Emails/Emails.php                     |  2 +-
 modules/Events/actions/Save.php               |  2 +-
 modules/Products/Products.php                 | 22 +++++++++----------
 modules/Quotes/Quotes.php                     |  2 +-
 modules/Reports/ReportRun.php                 |  7 +++---
 modules/Reports/ReportUtils.php               |  1 +
 modules/Reports/Reports.php                   |  6 ++---
 modules/Reports/models/Chart.php              |  1 +
 modules/Settings/Currency/models/Record.php   |  6 ++---
 .../Settings/LayoutEditor/models/Module.php   |  2 +-
 modules/Settings/LayoutEditor/views/Index.php |  2 +-
 .../MailConverter/handlers/MailRecord.php     |  8 +++----
 .../ModuleManager/models/Extension.php        |  5 ++---
 modules/Settings/Profiles/models/Record.php   | 10 ++++-----
 .../models/EditTaskRecordStructure.php        |  5 +++--
 modules/Settings/Workflows/models/Record.php  |  2 +-
 modules/Users/CreateUserPrivilegeFile.php     |  2 +-
 modules/Users/Users.php                       | 14 ++++--------
 modules/Vtiger/actions/ExportData.php         |  2 +-
 modules/Vtiger/actions/TagCloud.php           | 10 ++-------
 modules/Vtiger/views/MassActionAjax.php       |  4 ++--
 .../CustomerPortal/apis/FetchRecords.php      |  8 +++----
 .../modules/CustomerPortal/helpers/Utils.php  | 10 ++++-----
 .../EmailTemplates/GridViewContents.tpl       |  4 ++--
 .../modules/EmailTemplates/ModuleHeader.tpl   |  4 ++--
 .../v7/modules/Import/ImportAdvanced.tpl      |  4 ++--
 .../v7/modules/Import/ImportBasicStep.tpl     |  6 ++---
 .../v7/modules/Import/ImportStepOne.tpl       |  2 +-
 .../v7/modules/Import/ImportStepThree.tpl     |  4 ++--
 .../Import/modules/Import/actions/Data.php    |  2 +-
 .../modules/MailManager/models/Message.php    |  4 ++--
 .../MailManager/views/MassActionAjax.php      |  2 +-
 .../modules/ModComments/ListViewContents.tpl  |  4 ++--
 .../v7/modules/Project/SelectEmailFields.tpl  |  2 +-
 .../modules/ProjectTask/SelectEmailFields.tpl |  6 ++---
 53 files changed, 111 insertions(+), 125 deletions(-)

diff --git a/data/CRMEntity.php b/data/CRMEntity.php
index cdb158b58..1c1eacd50 100644
--- a/data/CRMEntity.php
+++ b/data/CRMEntity.php
@@ -650,7 +650,7 @@ class CRMEntity {
 						if(php7_count($IMG_FILES)){
 							foreach($IMG_FILES as $fileIndex => $file) {
 								if($file['error'] == 0 && $file['name'] != '' && $file['size'] > 0) {
-									if(isset($_REQUEST[$fileIndex.'_hidden']) && $_REQUEST[$fileIndex] != '') {
+									if(isset($_REQUEST[$fileIndex.'_hidden']) && $_REQUEST[$fileIndex.'_hidden'] != '') {
 										$file['original_name'] = vtlib_purify($_REQUEST[$fileIndex.'_hidden']);
 									} else {
 										$file['original_name'] = stripslashes($file['name']);
diff --git a/include/utils/EditViewUtils.php b/include/utils/EditViewUtils.php
index be21fb0c6..2560e9360 100755
--- a/include/utils/EditViewUtils.php
+++ b/include/utils/EditViewUtils.php
@@ -236,7 +236,7 @@ function getAssociatedProducts($module, $focus, $seid = '', $refModuleName = fal
 			$product_Detail[$i]['delRow'.$i]="Del";
 		}
 
-		if (in_array($module, $lineItemSupportedModules) || $module === 'Vendors' || isset($focus->mode) && (!$focus->mode && $seid)) {
+		if (in_array($module, $lineItemSupportedModules) || $module === 'Vendors' || (!isset($focus->mode) && $seid) || (!$focus->mode && $seid)) {
 			$subProductsQuery = 'SELECT vtiger_seproductsrel.crmid AS prod_id, quantity FROM vtiger_seproductsrel
 								 INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_seproductsrel.crmid
 								 INNER JOIN vtiger_products ON vtiger_products.productid = vtiger_seproductsrel.crmid
@@ -627,4 +627,4 @@ function split_validationdataArray($validationData)
 }
 
 
-?>
\ No newline at end of file
+?>
diff --git a/layouts/v7/modules/Documents/ModuleHeader.tpl b/layouts/v7/modules/Documents/ModuleHeader.tpl
index 92ebd4333..28bd2c43c 100644
--- a/layouts/v7/modules/Documents/ModuleHeader.tpl
+++ b/layouts/v7/modules/Documents/ModuleHeader.tpl
@@ -41,7 +41,7 @@
 					<p  class="current-filter-name filter-name pull-left cursorPointer" title="{$CVNAME}">&nbsp;<span class="fa fa-angle-right pull-left" aria-hidden="true"></span><a  href='{$MODULE_MODEL->getListViewUrl()}&viewname={$VIEWID}'>&nbsp;{$CVNAME}&nbsp;</a> </p>
 				{/if}
 				{assign var=SINGLE_MODULE_NAME value='SINGLE_'|cat:$MODULE}
-				{if isset($RECORD) and $REQ->get('view') eq 'Edit'}
+				{if isset($RECORD) and $RECORD and $REQ->get('view') eq 'Edit'}
 					<p class="current-filter-name filter-name pull-left "><span class="fa fa-angle-right pull-left" aria-hidden="true"></span><a title="{$RECORD->get('label')}">&nbsp;{vtranslate('LBL_EDITING', $MODULE)} : {$RECORD->get('label')}&nbsp;</a></p>
 				{else if $REQ->get('view') eq 'Edit'}
 					<p class="current-filter-name filter-name pull-left "><span class="fa fa-angle-right pull-left" aria-hidden="true"></span><a>&nbsp;{vtranslate('LBL_ADDING_NEW', $MODULE)}&nbsp;</a></p>
diff --git a/layouts/v7/modules/Documents/partials/SidebarEssentials.tpl b/layouts/v7/modules/Documents/partials/SidebarEssentials.tpl
index 29fda74cd..f6a3105a8 100644
--- a/layouts/v7/modules/Documents/partials/SidebarEssentials.tpl
+++ b/layouts/v7/modules/Documents/partials/SidebarEssentials.tpl
@@ -152,7 +152,7 @@
             <div class="menu-scroller scrollContainer" style="position:relative; top:0; left:0;">
                         <div class="list-menu-content">
                             <div id="listViewTagContainer" class="multiLevelTagList" 
-                            {if isset($ALL_CUSTOMVIEW_MODEL)} data-view-id="{$ALL_CUSTOMVIEW_MODEL->getId()}" {/if}
+                            {if isset($ALL_CUSTOMVIEW_MODEL) && $ALL_CUSTOMVIEW_MODEL} data-view-id="{$ALL_CUSTOMVIEW_MODEL->getId()}" {/if}
                             data-list-tag-count="{Vtiger_Tag_Model::NUM_OF_TAGS_LIST}">
                                 {foreach item=TAG_MODEL from=$TAGS name=tagCounter}
                                     {assign var=TAG_LABEL value=$TAG_MODEL->getName()}
diff --git a/layouts/v7/modules/Events/partials/EditViewContents.tpl b/layouts/v7/modules/Events/partials/EditViewContents.tpl
index 25c1ebda7..fcdb7f4e7 100644
--- a/layouts/v7/modules/Events/partials/EditViewContents.tpl
+++ b/layouts/v7/modules/Events/partials/EditViewContents.tpl
@@ -12,7 +12,7 @@
 {strip}
 	{include file="partials/EditViewContents.tpl"|@vtemplate_path:'Vtiger'}
 	<div name='editContent'>
-		<div class='fieldBlockContainer' data-block="{(isset($BLOCK_LABEL)) ? $BLOCK_LABEL :""}">
+		<div class='fieldBlockContainer' data-block="{(isset($BLOCK_LABEL)) ? $BLOCK_LABEL :''}">
 			<h4 class='fieldBlockHeader'>{vtranslate('LBL_INVITE_USER_BLOCK', $MODULE)}</h4>
 			<hr>
 			<table class="table table-borderless">
@@ -72,4 +72,4 @@
 			<!--Confirmation modal for updating Recurring Events--> 
 		</div>
 	</div>
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/layouts/v7/modules/Events/uitypes/Multireference.tpl b/layouts/v7/modules/Events/uitypes/Multireference.tpl
index d4ac80fd9..4a066ec7f 100644
--- a/layouts/v7/modules/Events/uitypes/Multireference.tpl
+++ b/layouts/v7/modules/Events/uitypes/Multireference.tpl
@@ -33,7 +33,7 @@
 		<div class="input-group">
 			<input id="{$FIELD_NAME}_display" name="{$FIELD_NAME}_display" data-fieldname="{$FIELD_NAME}" data-fieldtype="reference" type="text" 
 				class="marginLeftZero autoComplete inputElement" 
-				value="{(isset($displayId))?$FIELD_MODEL->getEditViewDisplayValue($displayId):""}" 
+				value="{(isset($displayId))?$FIELD_MODEL->getEditViewDisplayValue($displayId):''}" 
 				data-fieldinfo='{json_encode($FIELD_INFO)}' data-fieldtype="multireference" placeholder="{vtranslate('LBL_TYPE_SEARCH',$MODULE)}"
 				{if $FIELD_INFO["mandatory"] eq true} data-rule-required="true" {/if}
 				/>
diff --git a/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl b/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl
index d507ad8ea..6c49eeda6 100644
--- a/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl
+++ b/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl
@@ -66,20 +66,20 @@
 	{if $PRODUCT_EDITABLE}
 		<td>
 			<!-- Product Re-Ordering Feature Code Addition Starts -->
-			<input type="hidden" name="hidtax_row_no{$row_no}" id="hidtax_row_no{$row_no}" value="{(isset($tax_row_no)) ? $tax_row_no : ""}"/>
+			<input type="hidden" name="hidtax_row_no{$row_no}" id="hidtax_row_no{$row_no}" value="{(isset($tax_row_no)) ? $tax_row_no : ''}"/>
 			<!-- Product Re-Ordering Feature Code Addition ends -->
 			<div class="itemNameDiv form-inline">
 				<div class="row">
 					<div class="col-lg-10">
 						<div class="input-group" style="width:100%">
-							<input type="text" id="{$productName}" name="{$productName}" value="{(isset($data.$productName)) ? $data.$productName : ""}" class="productName form-control {if $row_no neq 0} autoComplete {/if} " placeholder="{vtranslate('LBL_TYPE_SEARCH',$MODULE)}"
+							<input type="text" id="{$productName}" name="{$productName}" value="{(isset($data.$productName)) ? $data.$productName : ''}" class="productName form-control {if $row_no neq 0} autoComplete {/if} " placeholder="{vtranslate('LBL_TYPE_SEARCH',$MODULE)}"
 								   data-rule-required=true {if !empty($data.$productName)} disabled="disabled" {/if}>
 							{if isset($data.$productDeleted) && !$data.$productDeleted}
 								<span class="input-group-addon cursorPointer clearLineItem" title="{vtranslate('LBL_CLEAR',$MODULE)}">
 									<i class="fa fa-times-circle"></i>
 								</span>
 							{/if}
-							<input type="hidden" id="{$hdnProductId}" name="{$hdnProductId}" value="{(isset($data.$hdnProductId)) ? $data.$hdnProductId : ""}" class="selectedModuleId"/>
+							<input type="hidden" id="{$hdnProductId}" name="{$hdnProductId}" value="{(isset($data.$hdnProductId)) ? $data.$hdnProductId : ''}" class="selectedModuleId"/>
 							<input type="hidden" id="lineItemType{$row_no}" name="lineItemType{$row_no}" value="{$entityType}" class="lineItemType"/>
 						</div>
 					</div>
@@ -101,7 +101,7 @@
 					</div>
 				</div>
 			</div>
-			<input type="hidden" value="{(isset($data.$subproduct_ids)) ? $data.$subproduct_ids : ""}" id="{$subproduct_ids}" name="{$subproduct_ids}" class="subProductIds" />
+			<input type="hidden" value="{(isset($data.$subproduct_ids)) ? $data.$subproduct_ids : ''}" id="{$subproduct_ids}" name="{$subproduct_ids}" class="subProductIds" />
 			<div id="{$subprod_names}" name="{$subprod_names}" class="subInformation">
 				<span class="subProductsContainer">
 				{if isset($data.$subprod_qty_list)}
@@ -223,19 +223,19 @@
 								</td>
 								<td>
 									<span class="pull-right">&nbsp;%</span>
-									<input type="text" data-rule-positive=true data-rule-inventory_percentage=true id="discount_percentage{$row_no}" name="discount_percentage{$row_no}" value="{(isset($data.$discount_percent)) ? $data.$discount_percent : ""}" class="discount_percentage span1 pull-right discountVal {if empty($data.$checked_discount_percent)}hide{/if}" />
+									<input type="text" data-rule-positive=true data-rule-inventory_percentage=true id="discount_percentage{$row_no}" name="discount_percentage{$row_no}" value="{(isset($data.$discount_percent)) ? $data.$discount_percent : ''}" class="discount_percentage span1 pull-right discountVal {if empty($data.$checked_discount_percent)}hide{/if}" />
 								</td>
 							</tr>
 						{/if}
 						{if $ITEM_DISCOUNT_AMOUNT_EDITABLE}
 							<tr>
 								<td class="LineItemDirectPriceReduction">
-									<input type="radio" name="discount{$row_no}" {(isset($data.$checked_discount_amount)) ? $data.$checked_discount_amount : ""} class="discounts" data-discount-type="amount" />
+									<input type="radio" name="discount{$row_no}" {(isset($data.$checked_discount_amount)) ? $data.$checked_discount_amount : ''} class="discounts" data-discount-type="amount" />
 									&nbsp;
 									{vtranslate('LBL_DIRECT_PRICE_REDUCTION',$MODULE)}
 								</td>
 								<td>
-									<input type="text" data-rule-positive=true id="discount_amount{$row_no}" name="discount_amount{$row_no}" value="{(isset($data.$discount_amount)) ? $data.$discount_amount : ""}" class="span1 pull-right discount_amount discountVal {if empty($data.$checked_discount_amount)}hide{/if}"/>
+									<input type="text" data-rule-positive=true id="discount_amount{$row_no}" name="discount_amount{$row_no}" value="{(isset($data.$discount_amount)) ? $data.$discount_amount : ''}" class="span1 pull-right discount_amount discountVal {if empty($data.$checked_discount_amount)}hide{/if}"/>
 								</td>
 							</tr>
 						{/if}
diff --git a/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl b/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl
index fa74b5c65..30e8ee238 100644
--- a/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl
+++ b/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl
@@ -67,7 +67,7 @@
 {/if}
 
 <input type="hidden" class="numberOfCurrencyDecimal" value="{$USER_MODEL->get('no_of_currency_decimals')}" />
-<input type="hidden" name="totalProductCount" id="totalProductCount" value="{(isset($row_no)) ? $row_no : ""}" />
+<input type="hidden" name="totalProductCount" id="totalProductCount" value="{(isset($row_no)) ? $row_no : ''}" />
 <input type="hidden" name="subtotal" id="subtotal" value="" />
 <input type="hidden" name="total" id="total" value="" />
 
@@ -281,13 +281,13 @@
 										{if $DISCOUNT_PERCENT_EDITABLE}
 											<tr>
 												<td><input type="radio" name="discount_final" class="finalDiscounts" data-discount-type="percentage" {if $DISCOUNT_TYPE_FINAL eq 'percentage'}checked{/if} />&nbsp; % {vtranslate('LBL_OF_PRICE',$MODULE)}</td>
-												<td><span class="pull-right">&nbsp;%</span><input type="text" data-rule-positive=true data-rule-inventory_percentage=true id="discount_percentage_final" name="discount_percentage_final" value="{(isset($FINAL.discount_percentage_final)) ? $FINAL.discount_percentage_final : ""}" class="discount_percentage_final span1 pull-right discountVal {if $DISCOUNT_TYPE_FINAL neq 'percentage'}hide{/if}" /></td>
+												<td><span class="pull-right">&nbsp;%</span><input type="text" data-rule-positive=true data-rule-inventory_percentage=true id="discount_percentage_final" name="discount_percentage_final" value="{(isset($FINAL.discount_percentage_final)) ? $FINAL.discount_percentage_final : ''}" class="discount_percentage_final span1 pull-right discountVal {if $DISCOUNT_TYPE_FINAL neq 'percentage'}hide{/if}" /></td>
 											</tr>
 										{/if}
 										{if $DISCOUNT_AMOUNT_EDITABLE}
 											<tr>
 												<td><input type="radio" name="discount_final" class="finalDiscounts" data-discount-type="amount" {if $DISCOUNT_TYPE_FINAL eq 'amount'}checked{/if} />&nbsp;{vtranslate('LBL_DIRECT_PRICE_REDUCTION',$MODULE)}</td>
-												<td><input type="text" data-rule-positive=true id="discount_amount_final" name="discount_amount_final" value="{(isset($FINAL.discount_amount_final)) ? $FINAL.discount_amount_final : ""}" class="span1 pull-right discount_amount_final discountVal {if $DISCOUNT_TYPE_FINAL neq 'amount'}hide{/if}" /></td>
+												<td><input type="text" data-rule-positive=true id="discount_amount_final" name="discount_amount_final" value="{(isset($FINAL.discount_amount_final)) ? $FINAL.discount_amount_final : ''}" class="span1 pull-right discount_amount_final discountVal {if $DISCOUNT_TYPE_FINAL neq 'amount'}hide{/if}" /></td>
 											</tr>
 										{/if}
 									</tbody>
@@ -338,7 +338,7 @@
 					</td>
 					<td>
 					
-						{assign var=PRE_TAX_TOTAL value="{(isset($FINAL.preTaxTotal)) ? $FINAL.preTaxTotal:""}"}
+						{assign var=PRE_TAX_TOTAL value="{(isset($FINAL.preTaxTotal)) ? $FINAL.preTaxTotal:''}"}
 						<span class="pull-right" id="preTaxTotal">{if $PRE_TAX_TOTAL}{$PRE_TAX_TOTAL}{else}0{/if}</span>
 						<input type="hidden" id="pre_tax_total" name="pre_tax_total" value="{if $PRE_TAX_TOTAL}{$PRE_TAX_TOTAL}{else}0{/if}"/>
 					</td>
diff --git a/layouts/v7/modules/Vtiger/AddCommentForm.tpl b/layouts/v7/modules/Vtiger/AddCommentForm.tpl
index ebb4b5bf6..6c338a623 100644
--- a/layouts/v7/modules/Vtiger/AddCommentForm.tpl
+++ b/layouts/v7/modules/Vtiger/AddCommentForm.tpl
@@ -21,7 +21,7 @@
             <input type="hidden" name="search_key" value= "{(isset($SEARCH_KEY)) ? $SEARCH_KEY : ''}" />
             <input type="hidden" name="operator" value="{$OPERATOR}" />
             <input type="hidden" name="search_value" value="{(isset($ALPHABET_VALUE)) ? $ALPHABET_VALUE : ''}" />
-            <input type="hidden" name="search_params" value='{(isset($SEARCH_PARAMS)) ? Vtiger_Util_Helper::toSafeHTML(ZEND_JSON::encode($SEARCH_PARAMS)) : ''}' />
+            <input type="hidden" name="search_params" value='{(isset($SEARCH_PARAMS)) ? Vtiger_Util_Helper::toSafeHTML(ZEND_JSON::encode($SEARCH_PARAMS)) : ""}' />
             <input type="hidden" name="tag_params" value={ZEND_JSON::encode($TAG_PARAMS)}>
 
             {assign var=HEADER_TITLE value={vtranslate('LBL_ADDING_COMMENT', $MODULE)}}
diff --git a/layouts/v7/modules/Vtiger/ListViewActions.tpl b/layouts/v7/modules/Vtiger/ListViewActions.tpl
index 9a5616c31..e7bbc94f9 100644
--- a/layouts/v7/modules/Vtiger/ListViewActions.tpl
+++ b/layouts/v7/modules/Vtiger/ListViewActions.tpl
@@ -98,7 +98,7 @@
                             {if $PRINT_TEMPLATE}
                                 <li class="hide"><a id="{$MODULE}_listView_advancedAction_{Vtiger_Util_Helper::replaceSpaceWithUnderScores($PRINT_TEMPLATE->getLabel())}" {if stripos($PRINT_TEMPLATE->getUrl(), 'javascript:')===0} href="javascript:void(0);" onclick='{$PRINT_TEMPLATE->getUrl()|substr:strlen("javascript:")};'{else} href='{$PRINT_TEMPLATE->getUrl()}' {/if}>{vtranslate($PRINT_TEMPLATE->getLabel(), $MODULE)}</a></li>
                             {/if}
-                            {if isset($FIND_DUPLICATES_EXISTS)}
+                            {if isset($FIND_DUPLICATES_EXISTS) && $FIND_DUPLICATES_EXISTS}
                                 <li class="hide"><a id="{$MODULE}_listView_advancedAction_MERGE_RECORD"  href="javascript:void(0);" onclick='Vtiger_List_Js.triggerMergeRecord()'>{vtranslate('LBL_MERGE_SELECTED_RECORDS', $MODULE)}</a></li>
                             {/if}
                             {foreach item=LISTVIEW_ADVANCEDACTIONS from=$LISTVIEW_LINKS['LISTVIEW']}
diff --git a/layouts/v7/modules/Vtiger/ListViewContents.tpl b/layouts/v7/modules/Vtiger/ListViewContents.tpl
index b5f0a1aa3..75aa0cf6a 100644
--- a/layouts/v7/modules/Vtiger/ListViewContents.tpl
+++ b/layouts/v7/modules/Vtiger/ListViewContents.tpl
@@ -39,7 +39,7 @@
 	<input type="hidden" name="noFilterCache" value="{(isset($NO_SEARCH_PARAMS_CACHE)) ? $NO_SEARCH_PARAMS_CACHE : ''}" id="noFilterCache" >
 	<input type="hidden" name="orderBy" value="{(isset($ORDER_BY)) ? $ORDER_BY : ''}" id="orderBy">
 	<input type="hidden" name="sortOrder" value="{(isset($SORT_ORDER)) ? $SORT_ORDER : ''}" id="sortOrder">
-	<input type="hidden" name="list_headers" value='{(isset($LIST_HEADER_FIELDS)) ? $LIST_HEADER_FIELDS : ''}'/>
+	<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}" />
diff --git a/layouts/v7/modules/Vtiger/PopupContents.tpl b/layouts/v7/modules/Vtiger/PopupContents.tpl
index ac63b9f60..c7a98f44c 100644
--- a/layouts/v7/modules/Vtiger/PopupContents.tpl
+++ b/layouts/v7/modules/Vtiger/PopupContents.tpl
@@ -84,7 +84,7 @@
                     {assign var="RECORD_DATA" value=$LISTVIEW_ENTRY->getRawData()}
                     <tr class="listViewEntries" data-id="{$LISTVIEW_ENTRY->getId()}" {if $MODULE eq 'EmailTemplates'} data-name="{$RECORD_DATA['subject']}" data-info="{$LISTVIEW_ENTRY->get('body')}" {else} data-name="{$LISTVIEW_ENTRY->getName()}" data-info='{Vtiger_Util_Helper::toSafeHTML(ZEND_JSON::encode($LISTVIEW_ENTRY->getRawData()))}' {/if}
                     {if isset($GETURL) && $GETURL neq ''} data-url='{$LISTVIEW_ENTRY->$GETURL()}' {/if}  id="{$MODULE}_popUpListView_row_{$smarty.foreach.popupListView.index+1}">
-                    {if isset($MULTI_SELECT)}
+                    {if isset($MULTI_SELECT) && $MULTI_SELECT}
                         <td class="{$WIDTHTYPE}">
                             <input class="entryCheckBox" type="checkbox" />
                         </td>
diff --git a/layouts/v7/modules/Vtiger/PopupNavigation.tpl b/layouts/v7/modules/Vtiger/PopupNavigation.tpl
index 43b9577ad..453ba318c 100644
--- a/layouts/v7/modules/Vtiger/PopupNavigation.tpl
+++ b/layouts/v7/modules/Vtiger/PopupNavigation.tpl
@@ -11,7 +11,7 @@
 
 {strip}
     <div class="col-md-2">
-        {if isset($MULTI_SELECT)}
+        {if isset($MULTI_SELECT) && $MULTI_SELECT}
             {if !empty($LISTVIEW_ENTRIES)}<button class="select btn btn-default" disabled="disabled"><strong>{vtranslate('LBL_ADD', $MODULE)}</strong></button>{/if}
         {else}
             &nbsp;
@@ -21,4 +21,4 @@
         {assign var=RECORD_COUNT value=$LISTVIEW_ENTRIES_COUNT}
         {include file="Pagination.tpl"|vtemplate_path:$MODULE SHOWPAGEJUMP=true}
     </div>
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/layouts/v7/modules/Vtiger/uitypes/Date.tpl b/layouts/v7/modules/Vtiger/uitypes/Date.tpl
index 21240aef4..7554d7169 100644
--- a/layouts/v7/modules/Vtiger/uitypes/Date.tpl
+++ b/layouts/v7/modules/Vtiger/uitypes/Date.tpl
@@ -13,7 +13,7 @@
 {assign var="FIELD_INFO" value=$FIELD_MODEL->getFieldInfo()}
 {assign var="SPECIAL_VALIDATOR" value=$FIELD_MODEL->getValidator()}
 {assign var="dateFormat" value=$USER_MODEL->get('date_format')}
-{if (!isset($FIELD_NAME))}
+{if (!isset($FIELD_NAME) || !$FIELD_NAME)}
   {assign var="FIELD_NAME" value=$FIELD_MODEL->getFieldName()}
 {/if}
 <div class="input-group inputElement" style="margin-bottom: 3px">
diff --git a/layouts/v7/modules/Vtiger/uitypes/Text.tpl b/layouts/v7/modules/Vtiger/uitypes/Text.tpl
index 31137741b..971be4272 100644
--- a/layouts/v7/modules/Vtiger/uitypes/Text.tpl
+++ b/layouts/v7/modules/Vtiger/uitypes/Text.tpl
@@ -12,7 +12,7 @@
 {strip}
 {assign var="FIELD_INFO" value=$FIELD_MODEL->getFieldInfo()}
 {assign var="SPECIAL_VALIDATOR" value=$FIELD_MODEL->getValidator()}
-{if !isset($FIELD_NAME)}
+{if !isset($FIELD_NAME) || !$FIELD_NAME}
   {assign var="FIELD_NAME" value=$FIELD_MODEL->getFieldName()}
 {/if}
 {assign var="fieldValue" value=purifyHtmlEventAttributes($FIELD_MODEL->get('fieldvalue'),true)}
diff --git a/modules/Campaigns/Campaigns.php b/modules/Campaigns/Campaigns.php
index d67ec6df0..7ba1fd70d 100644
--- a/modules/Campaigns/Campaigns.php
+++ b/modules/Campaigns/Campaigns.php
@@ -537,6 +537,7 @@ class Campaigns extends CRMEntity {
 
 		if(!isset($this->campaignrelstatus))
 		{
+			$this->campaignrelstatus = array();
 			$result = $adb->pquery('SELECT * FROM vtiger_campaignrelstatus;', array());
 			while($row = $adb->fetchByAssoc($result))
 			{
diff --git a/modules/CustomView/models/Record.php b/modules/CustomView/models/Record.php
index 3066fef56..2c3f31436 100644
--- a/modules/CustomView/models/Record.php
+++ b/modules/CustomView/models/Record.php
@@ -356,7 +356,7 @@ class CustomView_Record_Model extends Vtiger_Base_Model {
 				if(empty($groupInfo)) continue;
 
 				$groupColumns = $groupInfo['columns'];
-				$groupCondition = isset($groupInfo['condition']);
+				$groupCondition = isset($groupInfo['condition'])?$groupInfo['condition']:null;
 
 				foreach($groupColumns as $columnIndex => $columnCondition) {
 					if(empty($columnCondition)) continue;
diff --git a/modules/Documents/views/QuickCreateAjax.php b/modules/Documents/views/QuickCreateAjax.php
index b2f0f81fc..1dbe570e8 100644
--- a/modules/Documents/views/QuickCreateAjax.php
+++ b/modules/Documents/views/QuickCreateAjax.php
@@ -81,7 +81,7 @@ class Documents_QuickCreateAjax_View extends Vtiger_IndexAjax_View {
 			$viewer->assign('RELATION_OPERATOR', $relationOperation);
 			$viewer->assign('PARENT_MODULE', $request->get('sourceModule'));
 			$viewer->assign('PARENT_ID', $request->get('sourceRecord'));
-			if (isset($relationFieldName)) {
+			if (isset($relationFieldName) && $relationFieldName) {
 				$viewer->assign('RELATION_FIELD_NAME', $relationFieldName);
 			}
 		}
diff --git a/modules/Emails/Emails.php b/modules/Emails/Emails.php
index e0e5c065a..2fbbf34d7 100644
--- a/modules/Emails/Emails.php
+++ b/modules/Emails/Emails.php
@@ -172,7 +172,7 @@ class Emails extends CRMEntity {
 		$file_saved = false;
 
 		//Added to send generated Invoice PDF with mail
-		$pdfAttached = isset($_REQUEST['pdf_attachment']);
+		$pdfAttached = isset($_REQUEST['pdf_attachment']) ? $_REQUEST['pdf_attachment'] : false;
 		//created Invoice pdf is attached with the mail
 		if (isset($_REQUEST['pdf_attachment']) && $_REQUEST['pdf_attachment'] != '') {
 			$file_saved = pdfAttach($this, $module, $pdfAttached, $id);
diff --git a/modules/Events/actions/Save.php b/modules/Events/actions/Save.php
index bc095debf..26094274a 100644
--- a/modules/Events/actions/Save.php
+++ b/modules/Events/actions/Save.php
@@ -80,7 +80,7 @@ class Events_Save_Action extends Calendar_Save_Action {
 		$recurObj = getrecurringObjValue();
 		$recurringDataChanged = Calendar_RepeatEvents::checkRecurringDataChanged($recurObj, $recurObjDb);
 		//TODO: remove the dependency on $_REQUEST
-		if((isset($_REQUEST['recurringtype']))&&($_REQUEST['recurringtype'] != '' && $_REQUEST['recurringtype'] != '--None--' && $recurringEditMode != 'current') || ($recurringDataChanged && empty($recurObj))) {
+		if((isset($_REQUEST['recurringtype']) &&($_REQUEST['recurringtype'] != '' && $_REQUEST['recurringtype'] != '--None--' && $recurringEditMode != 'current')) || ($recurringDataChanged && empty($recurObj))) {
 			$focus =  CRMEntity::getInstance('Events');
 			//get all the stored data to this object
 			$focus->column_fields = new TrackableObject($recordModel->getData());
diff --git a/modules/Products/Products.php b/modules/Products/Products.php
index f3ca58feb..3bec58aef 100755
--- a/modules/Products/Products.php
+++ b/modules/Products/Products.php
@@ -88,18 +88,18 @@ class Products extends CRMEntity {
 	function save_module($module)
 	{
 		//Inserting into product_taxrel table
-		if(isset($_REQUEST['ajxaction']) != 'DETAILVIEW' && isset($_REQUEST['action']) != 'ProcessDuplicates' && !$this->isWorkFlowFieldUpdate)
+		if((isset($_REQUEST['ajxaction']) && $_REQUEST['ajxaction'] != 'DETAILVIEW') && (isset($_REQUEST['action']) && $_REQUEST['action'] != 'ProcessDuplicates') && !$this->isWorkFlowFieldUpdate)
 		{
-			if (isset($_REQUEST['ajxaction']) != 'CurrencyUpdate') {
+			if (isset($_REQUEST['ajxaction']) && $_REQUEST['ajxaction'] != 'CurrencyUpdate') {
 				$this->insertTaxInformation('vtiger_producttaxrel', 'Products');
 			}
 
-			if (isset($_REQUEST['action']) != 'MassEditSave' ) {
+			if (isset($_REQUEST['action']) && $_REQUEST['action'] != 'MassEditSave' ) {
 				$this->insertPriceInformation('vtiger_productcurrencyrel', 'Products');
 			}
 		}
 
-		if(isset($_REQUEST['action']) == 'SaveAjax' && isset($_REQUEST['base_currency']) && isset($_REQUEST['unit_price'])){
+		if((isset($_REQUEST['action']) && $_REQUEST['action'] == 'SaveAjax') && isset($_REQUEST['base_currency']) && isset($_REQUEST['unit_price'])){
 			$this->insertPriceInformation('vtiger_productcurrencyrel', 'Products');
 		}
 		// Update unit price value in vtiger_productcurrencyrel
@@ -123,7 +123,7 @@ class Products extends CRMEntity {
 		$tax_per = '';
 		//Save the Product - tax relationship if corresponding tax check box is enabled
 		//Delete the existing tax if any
-		if($this->mode == 'edit' && isset($_REQUEST['action']) != 'MassEditSave')
+		if($this->mode == 'edit' && (isset($_REQUEST['action']) && $_REQUEST['action'] != 'MassEditSave'))
 		{
 			for($i=0;$i<php7_count($tax_details);$i++)
 			{
@@ -141,8 +141,8 @@ class Products extends CRMEntity {
 				$taxid = getTaxId($tax_name);
 				$tax_per = $_REQUEST[$tax_name];
 
-				$taxRegions = isset($_REQUEST[$tax_name.'_regions']);
-				if ($taxRegions || isset($_REQUEST[$tax_name.'_defaultPercentage']) != '') {
+				$taxRegions = isset($_REQUEST[$tax_name.'_regions']) ? $_REQUEST[$tax_name.'_regions']:"";
+				if ($taxRegions || (isset($_REQUEST[$tax_name.'_defaultPercentage']) && $_REQUEST[$tax_name.'_defaultPercentage'] != '')) {
 					$tax_per = $_REQUEST[$tax_name.'_defaultPercentage'];
 				} else {
 					$taxRegions = array();
@@ -156,7 +156,7 @@ class Products extends CRMEntity {
 
 				$log->debug("Going to save the Product - $tax_name tax relationship");
 
-				if (isset($_REQUEST['action']) === 'MassEditSave') {
+				if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'MassEditSave') {
 					$adb->pquery('DELETE FROM vtiger_producttaxrel WHERE productid=? AND taxid=?', array($this->id, $taxid));
 				}
 
@@ -182,7 +182,7 @@ class Products extends CRMEntity {
 		$currency_details = getAllCurrencies('all');
 
 		//Delete the existing currency relationship if any
-		if($this->mode == 'edit' && isset($_REQUEST['action']) !== 'CurrencyUpdate')
+		if($this->mode == 'edit' && (isset($_REQUEST['action']) && $_REQUEST['action'] !== 'CurrencyUpdate'))
 		{
 			for($i=0;$i<php7_count($currency_details);$i++)
 			{
@@ -205,7 +205,7 @@ class Products extends CRMEntity {
 			$requestPrice = CurrencyField::convertToDBFormat($_REQUEST['unit_price'], null, true);
 			$actualPrice = CurrencyField::convertToDBFormat($_REQUEST[$cur_valuename], null, true);
 			$isQuickCreate = false;
-			if(isset($_REQUEST['action'])=='SaveAjax' && isset($_REQUEST['base_currency']) && $_REQUEST['base_currency'] == $cur_valuename){
+			if((isset($_REQUEST['action']) && $_REQUEST['action'] =='SaveAjax') && isset($_REQUEST['base_currency']) && $_REQUEST['base_currency'] == $cur_valuename){
 				$actualPrice = $requestPrice;
 				$isQuickCreate = true;
 			}
@@ -218,7 +218,7 @@ class Products extends CRMEntity {
 
 				$log->debug("Going to save the Product - $curname currency relationship");
 
-				if (isset($_REQUEST['action']) === 'CurrencyUpdate') {
+				if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'CurrencyUpdate') {
 					$adb->pquery('DELETE FROM vtiger_productcurrencyrel WHERE productid=? AND currencyid=?', array($this->id, $curid));
 				}
 
diff --git a/modules/Quotes/Quotes.php b/modules/Quotes/Quotes.php
index 7b57ba6ad..c9fc55129 100755
--- a/modules/Quotes/Quotes.php
+++ b/modules/Quotes/Quotes.php
@@ -127,7 +127,7 @@ class Quotes extends CRMEntity {
 		}
 		$_REQUEST['ajxaction']=isset($_REQUEST['ajxaction']) ? $_REQUEST['ajxaction'] :"";
 		//in ajax save we should not call this function, because this will delete all the existing product values
-		if($_REQUEST['action'] != 'QuotesAjax' && isset($_REQUEST['ajaxaction']) && $_REQUEST['ajxaction'] != 'DETAILVIEW'
+		if($_REQUEST['action'] != 'QuotesAjax' && isset($_REQUEST['ajxaction']) && $_REQUEST['ajxaction'] != 'DETAILVIEW'
 				&& $_REQUEST['action'] != 'MassEditSave' && $_REQUEST['action'] != 'ProcessDuplicates'
 				&& $_REQUEST['action'] != 'SaveAjax' && $this->isLineItemUpdate != false) {
 			//Based on the total Number of rows we will save the product relationship with this entity
diff --git a/modules/Reports/ReportRun.php b/modules/Reports/ReportRun.php
index 2488b29c5..eb0d5469a 100644
--- a/modules/Reports/ReportRun.php
+++ b/modules/Reports/ReportRun.php
@@ -461,7 +461,7 @@ class ReportRun extends CRMEntity {
 			if ($this->secondarymodule) {
 				$secondaryModules = explode(':', $this->secondarymodule);
 				foreach ($secondaryModules as $secondaryModule) {
-                    $columnsSelected = isset($selectedModuleFields[$secondaryModule]) ? (array)$selectedModuleFields[$secondaryModule] : [];
+                    $columnsSelected = isset($selectedModuleFields[$secondaryModule]) ? (array)$selectedModuleFields[$secondaryModule] : array();
 					$moduleModel = Vtiger_Module_Model::getInstance($secondaryModule);
                     /**
                      * To check whether any column is selected from secondary module. If so, then only add 
@@ -3931,13 +3931,14 @@ class ReportRun extends CRMEntity {
 		} elseif ($outputformat == "PRINT") {
 			$reportData = $this->GenerateReport('PDF', $filtersql);
 			$header = '';
+			$valtemplate = '';
 			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) || isset($key) && $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>';
@@ -4011,7 +4012,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;
diff --git a/modules/Reports/ReportUtils.php b/modules/Reports/ReportUtils.php
index 9fbda724d..991b6f76d 100644
--- a/modules/Reports/ReportUtils.php
+++ b/modules/Reports/ReportUtils.php
@@ -72,6 +72,7 @@ function IsDateField($reportColDetails) {
 			return false;
 		}
 	}
+	return false;
 }
 
 /**
diff --git a/modules/Reports/Reports.php b/modules/Reports/Reports.php
index 1dd9f3e39..0500e8dd6 100644
--- a/modules/Reports/Reports.php
+++ b/modules/Reports/Reports.php
@@ -614,8 +614,7 @@ class Reports extends CRMEntity{
 	function getPriModuleColumnsList($module)
 	{
 		//$this->updateModuleList($module);
-		$tempColumnsListByBlocks =$this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true);
-		$allColumnsListByBlocks = & $tempColumnsListByBlocks;
+		$allColumnsListByBlocks = $this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true);
 		foreach($this->module_list[$module] as $key=>$value) {
 			$temp = isset($allColumnsListByBlocks[$key]) ? $allColumnsListByBlocks[$key] : array();
 
@@ -699,8 +698,7 @@ class Reports extends CRMEntity{
 
 	public function getModuleFieldList($module) {
 		$ret_module_list = array();
-		$tempColumnsListByBlocks =$this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true);
-		$allColumnsListByBlocks = & $tempColumnsListByBlocks;
+		$allColumnsListByBlocks =$this->getColumnsListbyBlock($module, array_keys($this->module_list[$module]), true);
 		foreach($this->module_list[$module] as $key=>$value) {
 			$ret_module_list[$module][$value] = $this->getBlockFieldList(
 					$module, $key, isset($ret_module_list[$module][$value]) ? $ret_module_list[$module][$value] : array(),$allColumnsListByBlocks);
diff --git a/modules/Reports/models/Chart.php b/modules/Reports/models/Chart.php
index 885be84e6..7f30b60ad 100644
--- a/modules/Reports/models/Chart.php
+++ b/modules/Reports/models/Chart.php
@@ -124,6 +124,7 @@ abstract class Base_Chart extends Vtiger_Base_Model{
 		if (property_exists($this, 'fieldModels')) {
 			return $this->fieldModels;
 		}
+		return array();
 	}
 
 	function setQueryColumns($columns) {
diff --git a/modules/Settings/Currency/models/Record.php b/modules/Settings/Currency/models/Record.php
index dc300cf3f..ad03505f7 100644
--- a/modules/Settings/Currency/models/Record.php
+++ b/modules/Settings/Currency/models/Record.php
@@ -109,9 +109,7 @@ class Settings_Currency_Record_Model extends Settings_Vtiger_Record_Model{
             $instance->setData($row);
             return $instance;
         }
-        else{
-            return null;
-        }
+	return null;
         
     }
     
@@ -172,4 +170,4 @@ class Settings_Currency_Record_Model extends Settings_Vtiger_Record_Model{
         return $instanceList;
     }
     
-}
\ No newline at end of file
+}
diff --git a/modules/Settings/LayoutEditor/models/Module.php b/modules/Settings/LayoutEditor/models/Module.php
index ec2dd7d3d..6b5d00004 100644
--- a/modules/Settings/LayoutEditor/models/Module.php
+++ b/modules/Settings/LayoutEditor/models/Module.php
@@ -26,7 +26,7 @@ class Settings_LayoutEditor_Module_Model extends Vtiger_Module_Model {
 			$fieldList = array();
 			$blocks = $this->getBlocks();
 			$blockId = array();
-			$moduleModel='';
+			$moduleModel=null;
 			foreach ($blocks as $block) {
 				//to skip events hardcoded block id
 				if($block->get('id') == 'EVENT_INVITE_USER_BLOCK_ID') {
diff --git a/modules/Settings/LayoutEditor/views/Index.php b/modules/Settings/LayoutEditor/views/Index.php
index b2547245b..e636beaeb 100644
--- a/modules/Settings/LayoutEditor/views/Index.php
+++ b/modules/Settings/LayoutEditor/views/Index.php
@@ -85,7 +85,7 @@ class Settings_LayoutEditor_Index_View extends Settings_Vtiger_Index_View {
 
 		foreach($blockModels as $blockLabel => $blockModel) {
 			$id=$blockModel->get('id');
-			$fieldModelList = isset($blockIdFieldMap[$id]) ? $blockIdFieldMap[$id] : '';
+			$fieldModelList = isset($blockIdFieldMap[$id]) ? $blockIdFieldMap[$id] : null;
 			$blockModel->setFields($fieldModelList);
 		}
 
diff --git a/modules/Settings/MailConverter/handlers/MailRecord.php b/modules/Settings/MailConverter/handlers/MailRecord.php
index 09f92068c..3f1b8ae02 100644
--- a/modules/Settings/MailConverter/handlers/MailRecord.php
+++ b/modules/Settings/MailConverter/handlers/MailRecord.php
@@ -222,11 +222,9 @@ class Vtiger_MailRecord {
 		$this->_from = $this->__getEmailIdList($mailheader->from);
 		$this->_fromname = property_exists($mailheader->from[0], 'personal') ? self::__mime_decode($mailheader->from[0]->personal) : '';
 
-				if(property_exists($mailheader,'to') && property_exists($mailheader,'cc') && property_exists($mailheader,'bcc')){
-					$this->_to   = $this->__getEmailIdList($mailheader->to);
-					$this->_cc   = $this->__getEmailIdList($mailheader->cc);
-					$this->_bcc  = $this->__getEmailIdList($mailheader->bcc);
-				}
+		$this->_to = property_exists($mailheader, 'to') ? $this->__getEmailIdList($mailheader->to) : array();
+		$this->_cc = property_exists($mailheader, 'cc') ? $this->__getEmailIdList($mailheader->cc) : array();
+		$this->_bcc = property_exists($mailheader, 'bcc') ? $this->__getEmailIdList($mailheader->bcc) : array();
 
 		$this->_date = $mailheader->udate;
 
diff --git a/modules/Settings/ModuleManager/models/Extension.php b/modules/Settings/ModuleManager/models/Extension.php
index c01c95343..80ba8bca2 100644
--- a/modules/Settings/ModuleManager/models/Extension.php
+++ b/modules/Settings/ModuleManager/models/Extension.php
@@ -19,8 +19,7 @@ class Settings_ModuleManager_Extension_Model extends Vtiger_Base_Model {
 	var $fileName;
 
 	public static function getUploadDirectory($isChild = false) {
-		if(!isset($uploadDir ))$uploadDir ='';
-		$uploadDir .= 'test/vtlib';
+		$uploadDir = 'test/vtlib';
 		if ($isChild) {
 			$uploadDir = '../'.$uploadDir;
 		}
@@ -256,4 +255,4 @@ class Settings_ModuleManager_Extension_Model extends Vtiger_Base_Model {
 		}
 		return false;
 	}
-}
\ No newline at end of file
+}
diff --git a/modules/Settings/Profiles/models/Record.php b/modules/Settings/Profiles/models/Record.php
index e77cedbb6..ca01c009d 100644
--- a/modules/Settings/Profiles/models/Record.php
+++ b/modules/Settings/Profiles/models/Record.php
@@ -511,11 +511,11 @@ class Settings_Profiles_Record_Model extends Settings_Vtiger_Record_Model {
 				$availableActionIds = array_keys($actionIdsList);
 
 				foreach ($availableActionIds as $actionId) {
-					if ($actionId === 0 && isset($actionPermissions[1]) && isset($actionPermissions[7])) {
+					if ($actionId === 0) {
 						//Save action permissions = Permissions of Create/Editview action
-						$actionPermissions[$actionId] = $actionPermissions[1] || $actionPermissions[7];
+						$actionPermissions[$actionId] = (isset($actionPermissions[1]) && $actionPermissions[1]) || isset($actionPermissions[7] && $actionPermissions[7]);
 					} else {
-						$actionPermissions[$actionId] = isset($actionPermissions[$actionId]) ? $actionPermissions[$actionId] : null;
+						$actionPermissions[$actionId] = isset($actionPermissions[$actionId]) ? $actionPermissions[$actionId] : 0;
 					}
 				}
                 
@@ -624,7 +624,7 @@ class Settings_Profiles_Record_Model extends Settings_Vtiger_Record_Model {
 		$params = array($profileId, $tabId, $isModulePermitted);
 		$db->pquery($sql, $params);
 
-		$fieldPermissions = isset($permissions['fields']) ? $permissions['fields'] : '';
+		$fieldPermissions = isset($permissions['fields']) ? $permissions['fields'] : array();
 		if(is_array($fieldPermissions)) {
 			foreach($fieldPermissions as $fieldId => $stateValue) {
 				$db->pquery('DELETE FROM vtiger_profile2field WHERE profileid=? AND tabid=? AND fieldid=?',
@@ -886,4 +886,4 @@ class Settings_Profiles_Record_Model extends Settings_Vtiger_Record_Model {
 			}
 		}
 	}
-}
\ No newline at end of file
+}
diff --git a/modules/Settings/Workflows/models/EditTaskRecordStructure.php b/modules/Settings/Workflows/models/EditTaskRecordStructure.php
index 0a2b1c6e4..b121e16e5 100644
--- a/modules/Settings/Workflows/models/EditTaskRecordStructure.php
+++ b/modules/Settings/Workflows/models/EditTaskRecordStructure.php
@@ -32,7 +32,7 @@ class Settings_Workflows_EditTaskRecordStructure_Model extends Settings_Workflow
 
 		$taskTypeModel = $this->getTaskRecordModel()->getTaskType();
 		$taskTypeName = $taskTypeModel->getName();
-		$moduleName = '';
+
 		if($taskTypeName == 'VTUpdateFieldsTask' || $taskTypeName == "VTCreateEntityTask"){
 			return parent::getStructure();
 		}
@@ -43,6 +43,7 @@ class Settings_Workflows_EditTaskRecordStructure_Model extends Settings_Workflow
 
 		$baseModuleModel = $moduleModel = $this->getModule();
 		$blockModelList = $moduleModel->getBlocks();
+		$moduleName = $moduleModel->getName();
 		foreach($blockModelList as $blockLabel=>$blockModel) {
 			$fieldModelList = $blockModel->getFields();
 			if (!empty ($fieldModelList)) {
@@ -177,4 +178,4 @@ class Settings_Workflows_EditTaskRecordStructure_Model extends Settings_Workflow
 		$this->structuredValues = $values;
 		return $values;
 	}
-}
\ No newline at end of file
+}
diff --git a/modules/Settings/Workflows/models/Record.php b/modules/Settings/Workflows/models/Record.php
index 444eac1f4..39e0818fb 100644
--- a/modules/Settings/Workflows/models/Record.php
+++ b/modules/Settings/Workflows/models/Record.php
@@ -528,7 +528,7 @@ class Settings_Workflows_Record_Model extends Settings_Vtiger_Record_Model {
 		$tasks = Settings_Workflows_TaskRecord_Model::getAllForWorkflow($this, true);
 		foreach($tasks as $task) {
 			$taskName = $task->getTaskType()->get('tasktypename');
-			$actions[$taskName] = isset($actions[$taskName]) ? $actions[$taskName] : null;
+			$actions[$taskName] = isset($actions[$taskName]) ? $actions[$taskName] : 0;
 			$actions[$taskName] = $actions[$taskName] + 1;
 		}
 		return $actions;
diff --git a/modules/Users/CreateUserPrivilegeFile.php b/modules/Users/CreateUserPrivilegeFile.php
index a7e735692..56e7b1329 100644
--- a/modules/Users/CreateUserPrivilegeFile.php
+++ b/modules/Users/CreateUserPrivilegeFile.php
@@ -1502,7 +1502,7 @@ function constructTwoDimensionalArray($var)
        		foreach ($var as $key => $secarr)
 		{
            		$code .= $key.'=>array(';
-				if(!is_iterable($secarr))continue;
+				if($secarr == null || !is_iterable($secarr))continue;
 			foreach($secarr as $seckey => $secvalue)
 			{
 				$code .= $seckey.'=>'.$secvalue.',';
diff --git a/modules/Users/Users.php b/modules/Users/Users.php
index 9b1ee1067..24ac38d3b 100755
--- a/modules/Users/Users.php
+++ b/modules/Users/Users.php
@@ -1769,8 +1769,7 @@ class Users extends CRMEntity {
 							unset($currencyId);
 					} else if($fieldName == 'language') {
 						foreach($allLanguages as $langKey => $langName) {
-							if(isset($fieldValue) && isset($langKey) && isset($langName))continue;
-							if(strtolower($fieldValue) == strtolower($langKey) || strtolower($fieldValue) == strtolower($langName)) {
+							if(strtolower($fieldValue ? $fieldValue : "") == strtolower($langKey ? $langKey : "") || strtolower($fieldValue ? $fieldValue : "") == strtolower($langName ? $langName : "")) {
 								$lang = $langKey;
 								break;
 							}
@@ -1784,12 +1783,8 @@ class Users extends CRMEntity {
 						$allUsers = Users_Record_Model::getAll();
 						$reportsTo = null;
 						foreach($allUsers as $user) {
-							
-							if (!$user->get('user_name') && !$user->get('userlabel')) {
-								continue;
-							}
-							$userName = strtolower($user->get('user_name'));
-							$firstLastName = strtolower($user->get('userlabel'));
+							$userName = strtolower($user->get('user_name') ? $user->get('user_name') : "");
+							$firstLastName = strtolower($user->get('userlabel') ? $user->get('userlabel') : "");
 							if(strtolower($fieldValue) == $userName || strtolower($fieldValue) == $firstLastName) {
 								$reportsTo = $user->getId();
 								break;
@@ -1802,8 +1797,7 @@ class Users extends CRMEntity {
 						$picklistValues = $fieldInstance->getPicklistValues();
 						$emptyValuedPicklistFields = array('defaulteventstatus', 'defaultactivitytype', 'reminder_interval');
 						foreach($picklistValues as $picklistKey => $picklistValue) {
-							if(!$fieldValue && !$picklistValue && !$picklistKey) continue;
-							if(strtolower($fieldValue) == strtolower($picklistKey) || strtolower($fieldValue) == strtolower($picklistValue)) {
+							if(strtolower($fieldValue) == strtolower($picklistKey) || strtolower($fieldValue) == strtolower($picklistValue ? $picklistValue : "")) {
 								$selectedValue = $picklistKey;
 								break;
 							}
diff --git a/modules/Vtiger/actions/ExportData.php b/modules/Vtiger/actions/ExportData.php
index 0d5b94452..7adda4bdb 100644
--- a/modules/Vtiger/actions/ExportData.php
+++ b/modules/Vtiger/actions/ExportData.php
@@ -325,7 +325,7 @@ class Vtiger_ExportData_Action extends Vtiger_Mass_Action {
 			} elseif($uitype == 52 || $type == 'owner') {
 				$value = Vtiger_Util_Helper::getOwnerName($value);
 			}elseif($type == 'reference'){
-				$value = isset($value) ? trim($value) :'';
+				$value = isset($value) && $value ? trim($value) :'';
 				if(!empty($value)) {
 					$parent_module = getSalesEntityType($value);
 					$displayValueArray = getEntityName($parent_module, $value);
diff --git a/modules/Vtiger/actions/TagCloud.php b/modules/Vtiger/actions/TagCloud.php
index e50d2522a..9c6c75cf5 100644
--- a/modules/Vtiger/actions/TagCloud.php
+++ b/modules/Vtiger/actions/TagCloud.php
@@ -95,14 +95,8 @@ class Vtiger_TagCloud_Action extends Vtiger_Mass_Action {
 		if(empty($newTags)) {
 			$newTags = array();
 		}
-		$existingTags = isset($tagsList['existing']);
-		if(empty($existingTags)) {
-			$existingTags = array();
-		}
-		$deletedTags = isset($tagsList['deleted']);
-		if(empty($deletedTags)) {
-			$deletedTags = array();
-		}
+		$existingTags = isset($tagsList['existing']) && $tagsList['existing'] ? $tagsList['existing'] : array();
+		$deletedTags = isset($tagsList['deleted']) && $tagsList['deleted'] ? $tagsList['deleted'] : array();
 		$newTagType = $request->get('newTagType');
 		$currentUser = Users_Record_Model::getCurrentUserModel();
 		$userId = $currentUser->getId();
diff --git a/modules/Vtiger/views/MassActionAjax.php b/modules/Vtiger/views/MassActionAjax.php
index d8eb6a4e7..3c3299e65 100644
--- a/modules/Vtiger/views/MassActionAjax.php
+++ b/modules/Vtiger/views/MassActionAjax.php
@@ -216,7 +216,7 @@ class Vtiger_MassActionAjax_View extends Vtiger_IndexAjax_View {
             $viewer->assign('SEARCH_KEY','');
 		}
         
-        $searchParams = !empty($request->get('search_params'))?$request->get('search_params'):' ';
+        $searchParams = !empty($request->get('search_params'))?$request->get('search_params'):'';
 		$viewer->assign('SEARCH_PARAMS',$searchParams);
         
 
@@ -252,7 +252,7 @@ class Vtiger_MassActionAjax_View extends Vtiger_IndexAjax_View {
 		
 		if($recipientPrefModel)
 		$recipientPrefs = $recipientPrefModel->getPreferences();
-		$moduleEmailPrefs = isset($recipientPrefs[$moduleModel->getId()]);
+		$moduleEmailPrefs = isset($recipientPrefs[$moduleModel->getId()]) ? $recipientPrefs[$moduleModel->getId()]:false;
 		$emailFields = $moduleModel->getFieldsByType('email');
         $accesibleEmailFields = array();
 		
diff --git a/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/apis/FetchRecords.php b/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/apis/FetchRecords.php
index de20de4f6..598646c29 100644
--- a/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/apis/FetchRecords.php
+++ b/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/apis/FetchRecords.php
@@ -96,7 +96,7 @@ class CustomerPortal_FetchRecords extends CustomerPortal_API_Abstract {
 					$sql = sprintf('SELECT %s FROM Faq WHERE faqstatus=\'Published\'', $fields);
 				}
 				$countResult = vtws_query($countSql, $current_user);
-				$count = isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
+				$count = $countResult && isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
 
 				$sql = sprintf('%s ORDER BY %s %s LIMIT %s,%s ;', $sql, $orderBy, $order, ($page * $pageLimit), $pageLimit);
 				$result = vtws_query($sql, $current_user);
@@ -126,7 +126,7 @@ class CustomerPortal_FetchRecords extends CustomerPortal_API_Abstract {
 				if ($mode == 'mine') {
 					$relatedId = $contactWebserviceId;
 					$countResult = vtws_query_related($countSql, $relatedId, $moduleLabel, $current_user);
-					$count = isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
+					$count = $countResult && isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
 
 					$limitClause = sprintf('ORDER BY %s %s LIMIT %s,%s', $orderBy, $order, ($page * $pageLimit), $pageLimit);
 					$result = vtws_query_related($sql, $relatedId, $moduleLabel, $current_user, $limitClause);
@@ -138,7 +138,7 @@ class CustomerPortal_FetchRecords extends CustomerPortal_API_Abstract {
 						$sql = $sql.' '.$limitClause;
 						$result = vtws_query($sql, $current_user);
 						$countResult = vtws_query($countSql, $current_user);
-						$count = isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
+						$count = $countResult && isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
 					} else {
 						if (!empty($accountId)) {
 							if ($defaultMode == 'all')
@@ -151,7 +151,7 @@ class CustomerPortal_FetchRecords extends CustomerPortal_API_Abstract {
 						}
 
 						$countResult = vtws_query_related($countSql, $relatedId, $moduleLabel, $current_user);
-						$count = isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
+						$count = $countResult && isset($countResult[0]['count']) ? $countResult[0]['count'] : '';
 
 						$limitClause = sprintf('ORDER BY %s %s LIMIT %s,%s', $orderBy, $order, ($page * $pageLimit), $pageLimit);
 						$result = vtws_query_related($sql, $relatedId, $moduleLabel, $current_user, $limitClause);
diff --git a/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/helpers/Utils.php b/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/helpers/Utils.php
index f2f3b5d1b..77ca7ea6d 100644
--- a/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/helpers/Utils.php
+++ b/pkg/vtiger/modules/CustomerPortal/modules/CustomerPortal/helpers/Utils.php
@@ -23,14 +23,14 @@ class CustomerPortal_Utils {
 		$imagePath = $adb->query_result($result, 0, 'path');
 		$imageName = $adb->query_result($result, 0, 'name');
 		$imageType = $adb->query_result($result, 0, 'type');
-		$imageOriginalName = isset($imageName) ? urlencode(decode_html($imageName)) : '';
+		$imageOriginalName = $imageName ? urlencode(decode_html($imageName)) : '';
 
 		if (!empty($imageName)) {
 			$imageDetails[] = array(
-				'id' => isset($imageId) ? $imageId : '',
-				'orgname' => isset($imageOriginalName) ? $imageOriginalName : '',
+				'id' => $imageId ? $imageId : '',
+				'orgname' => $imageOriginalName ? $imageOriginalName : '',
 				'path' => $imagePath.$imageId,
-				'name' => isset($imageName) ? $imageName : '',
+				'name' => $imageName ? $imageName : '',
 				'type' => $imageType
 			);
 		}
@@ -92,7 +92,7 @@ class CustomerPortal_Utils {
 	static function resolveRecordValues(&$record, $user = null, $ignoreUnsetFields = false) {
 		$userTypeFields = array('assigned_user_id', 'creator', 'userid', 'created_user_id', 'modifiedby', 'folderid');
 
-		if (empty($record) || empty($user))
+		if (empty($record) || !$user)
 			return $record;
 
 		$module = Vtiger_Util_Helper::detectModulenameFromRecordId($record['id']);
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 53d14e7c1..144d4ca0e 100644
--- a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/GridViewContents.tpl
+++ b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/GridViewContents.tpl
@@ -26,7 +26,7 @@
 	<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='{(isset($LIST_HEADER_FIELDS)) ? $LIST_HEADER_FIELDS :''}'/>
+	<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}" />
@@ -59,4 +59,4 @@
                 </li>
             {/foreach}
         </div>   
-</div>
\ No newline at end of file
+</div>
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 e21fae9aa..5044ebf6d 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 isset($RECORD) and $REQ->get('view') eq 'Edit'}
+					{if isset($RECORD) and $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>
@@ -83,4 +83,4 @@
 			</script>
 		{/if}
 	</div>
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl
index 210e175d2..6720f986f 100644
--- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl
+++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportAdvanced.tpl
@@ -27,9 +27,9 @@
 
             <div class='modal-body'>
 				{assign var=LABELS value=[]}
-                {if isset($FORMAT) eq 'vcf'}
+                {if isset($FORMAT) && $FORMAT eq 'vcf'}
                     {$LABELS["step1"] = 'LBL_UPLOAD_VCF'}
-                {else if isset($FORMAT) eq 'ics'}
+                {else if isset($FORMAT) && $FORMAT eq 'ics'}
 					{$LABELS["step1"] = 'LBL_UPLOAD_ICS'}
 				{else}
                     {$LABELS["step1"] = 'LBL_UPLOAD_CSV'}
diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl
index 966cd6887..59c3a1d40 100644
--- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl
+++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportBasicStep.tpl
@@ -32,7 +32,7 @@
 					{/if}
 
 					{if $FORMAT neq 'ics'}
-						{if isset($DUPLICATE_HANDLING_NOT_SUPPORTED) eq 'true'}
+						{if isset($DUPLICATE_HANDLING_NOT_SUPPORTED) && $DUPLICATE_HANDLING_NOT_SUPPORTED eq 'true'}
 							{$LABELS["step3"] = 'LBL_FIELD_MAPPING'}
 						{else}
 							{$LABELS["step2"] = 'LBL_DUPLICATE_HANDLING'}
@@ -56,7 +56,7 @@
 						&nbsp;&nbsp;&nbsp;<a class="cancelLink" data-dismiss="modal" href="#">{vtranslate('LBL_CANCEL', $MODULE)}</a>
 					{else}
 						<div id="importStepOneButtonsDiv">
-							{if isset($DUPLICATE_HANDLING_NOT_SUPPORTED) eq 'true'}
+							{if isset($DUPLICATE_HANDLING_NOT_SUPPORTED) && $DUPLICATE_HANDLING_NOT_SUPPORTED eq 'true'}
 								<button class="btn btn-success btn-lg" id="skipDuplicateMerge" onclick="Vtiger_Import_Js.uploadAndParse('0');">{vtranslate('LBL_NEXT_BUTTON_LABEL', $MODULE)}</button>
 							{else}
 								<button class="btn btn-success btn-lg" id ="importStep2" onclick="Vtiger_Import_Js.importActionStep2();">{vtranslate('LBL_NEXT_BUTTON_LABEL', $MODULE)}</button>
@@ -74,4 +74,4 @@
 			</div>
 		</div>
 	</div>
-{/strip}
\ No newline at end of file
+{/strip}
diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl
index 6629fb095..f7adc41b5 100644
--- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl
+++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepOne.tpl
@@ -71,7 +71,7 @@
                     {/foreach}
                 </td>
             </tr>
-            {if isset($MULTI_CURRENCY)}
+            {if isset($MULTI_CURRENCY) && $MULTI_CURRENCY}
                 <tr id="lineitem_currency_container" style="height:50px">
                     <td>{vtranslate('LBL_IMPORT_LINEITEMS_CURRENCY',$MODULE)}</td>
                     <td>
diff --git a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl
index 517634478..f25e42405 100644
--- a/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl
+++ b/pkg/vtiger/modules/Import/layouts/v7/modules/Import/ImportStepThree.tpl
@@ -19,7 +19,7 @@
     <input type="checkbox" name="save_map" id="save_map">&nbsp;&nbsp;<label for="save_map">{'LBL_SAVE_AS_CUSTOM_MAPPING'|@vtranslate:$MODULE}</label>
     &nbsp;&nbsp;<input type="text" name="save_map_as" id="save_map_as" class = "form-control">
 </div>
-{if !isset($IMPORTABLE_FIELDS)}
+{if !isset($IMPORTABLE_FIELDS) || !$IMPORTABLE_FIELDS}
 	{assign var=IMPORTABLE_FIELDS value=$AVAILABLE_FIELDS}
 {/if}
-{include file="Import_Default_Values_Widget.tpl"|@vtemplate_path:'Import' IMPORTABLE_FIELDS=$IMPORTABLE_FIELDS}
\ No newline at end of file
+{include file="Import_Default_Values_Widget.tpl"|@vtemplate_path:'Import' IMPORTABLE_FIELDS=$IMPORTABLE_FIELDS}
diff --git a/pkg/vtiger/modules/Import/modules/Import/actions/Data.php b/pkg/vtiger/modules/Import/modules/Import/actions/Data.php
index 07bc71fed..6a20e2383 100644
--- a/pkg/vtiger/modules/Import/modules/Import/actions/Data.php
+++ b/pkg/vtiger/modules/Import/modules/Import/actions/Data.php
@@ -652,7 +652,7 @@ class Import_Data_Action extends Vtiger_Action_Controller {
 						unset($this->allPicklistValues[$fieldName]);
 					}
 				} else {
-					$fieldData[$fieldName] = isset($picklistDetails[$picklistValueInLowerCase]);
+					$fieldData[$fieldName] = isset($picklistDetails[$picklistValueInLowerCase]) ? $picklistDetails[$picklistValueInLowerCase] : null;
 				}
 			} else if ($fieldDataType == 'currency') {
 				// While exporting we are exporting as user format, we should import as db format while importing
diff --git a/pkg/vtiger/modules/MailManager/modules/MailManager/models/Message.php b/pkg/vtiger/modules/MailManager/modules/MailManager/models/Message.php
index d71e845ce..7af94cb8c 100644
--- a/pkg/vtiger/modules/MailManager/modules/MailManager/models/Message.php
+++ b/pkg/vtiger/modules/MailManager/modules/MailManager/models/Message.php
@@ -106,7 +106,7 @@ class MailManager_Message_Model extends Vtiger_MailRecord  {
 		// ATTACHMENT
     	// Any part with a filename is an attachment,
 	    // so an attached text file (type 0) is not mistaken as the message.
-    	if ((isset($params['filename']) || isset($params['name'])) && strtolower($p->disposition) == "attachment") {
+    	if (((isset($params['filename']) && $params['filename']) || (isset($params['name']) && $params['name'])) && strtolower($p->disposition) == "attachment") {
         	// filename may be given as 'Filename' or 'Name' or both
 	        $filename = ($params['filename'])? $params['filename'] : $params['name'];
 			// filename may be encoded, so see imap_mime_header_decode()
@@ -121,7 +121,7 @@ class MailManager_Message_Model extends Vtiger_MailRecord  {
 				$filename = $id;
 			}
 			$this->_inline_attachments[] = array('cid'=>$id, 'filename'=>@self::__mime_decode($filename), 'data' => $data);
-		} elseif((isset($params['filename']) || isset($params['name'])) && $p->bytes > 0) {
+		} elseif(( (isset($params['filename']) && $params['filename']) || (isset($params['name']) && $params['name'])) && $p->bytes > 0) {
 			$filename = ($params['filename'])? $params['filename'] : $params['name'];
 			$this->_attachments[] = array('filename' => @self::__mime_decode($filename), 'data' => $data);
 		}
diff --git a/pkg/vtiger/modules/MailManager/modules/MailManager/views/MassActionAjax.php b/pkg/vtiger/modules/MailManager/modules/MailManager/views/MassActionAjax.php
index 01d361049..af1012db2 100644
--- a/pkg/vtiger/modules/MailManager/modules/MailManager/views/MassActionAjax.php
+++ b/pkg/vtiger/modules/MailManager/modules/MailManager/views/MassActionAjax.php
@@ -55,7 +55,7 @@ class MailManager_MassActionAjax_View extends Vtiger_MassActionAjax_View {
 			}
 
 			$emailFields = $accesibleEmailFields;
-			$recordIds = '';
+			$recordIds = array();
 			if (php7_count($emailFields) > 0) {
 				$recordIds = $this->getRecordsListFromRequest($request);
 				global $current_user;
diff --git a/pkg/vtiger/modules/ModComments/layouts/v7/modules/ModComments/ListViewContents.tpl b/pkg/vtiger/modules/ModComments/layouts/v7/modules/ModComments/ListViewContents.tpl
index b5651ae27..37ea9657c 100644
--- a/pkg/vtiger/modules/ModComments/layouts/v7/modules/ModComments/ListViewContents.tpl
+++ b/pkg/vtiger/modules/ModComments/layouts/v7/modules/ModComments/ListViewContents.tpl
@@ -27,7 +27,7 @@
     <input type="hidden" name="noFilterCache" value="{(isset($NO_SEARCH_PARAMS_CACHE)) ? $NO_SEARCH_PARAMS_CACHE : ''}" id="noFilterCache" >
     <input type="hidden" name="orderBy" value="{(isset($ORDER_BY)) ? $ORDER_BY : ''}" id="orderBy">
     <input type="hidden" name="sortOrder" value="{(isset($SORT_ORDER)) ? $SORT_ORDER : ''}" id="sortOrder">
-    <input type="hidden" name="list_headers" value='{(isset($LIST_HEADER_FIELDS)) ? $LIST_HEADER_FIELDS : ''}'/>
+    <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}" />
@@ -115,7 +115,7 @@
                                 {assign var=DATA_URL value=$RELATED_TO->getDetailViewUrl()}
                             {/if}
                         {/if}
-                        <tr class="listViewEntries" data-id='{$DATA_ID}' data-recordUrl='{$DATA_URL}&app={(isset($SELECTED_MENU_CATEGORY)) ? $SELECTED_MENU_CATEGORY : ''}' id="{$MODULE}_listView_row_{$smarty.foreach.listview.index+1}" {if $MODULE eq 'Calendar'}data-recurring-enabled='{$LISTVIEW_ENTRY->isRecurringEnabled()}'{/if}>
+                        <tr class="listViewEntries" data-id='{$DATA_ID}' data-recordUrl='{$DATA_URL}&app={(isset($SELECTED_MENU_CATEGORY)) ? $SELECTED_MENU_CATEGORY : ""}' id="{$MODULE}_listView_row_{$smarty.foreach.listview.index+1}" {if $MODULE eq 'Calendar'}data-recurring-enabled='{$LISTVIEW_ENTRY->isRecurringEnabled()}'{/if}>
                             <td class = "listViewRecordActions">&nbsp;</td>
                             {foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
                                 {assign var=LISTVIEW_HEADERNAME value=$LISTVIEW_HEADER->get('name')}
diff --git a/pkg/vtiger/modules/Projects/Project/layouts/v7/modules/Project/SelectEmailFields.tpl b/pkg/vtiger/modules/Projects/Project/layouts/v7/modules/Project/SelectEmailFields.tpl
index fccf3eb07..1cce92be7 100644
--- a/pkg/vtiger/modules/Projects/Project/layouts/v7/modules/Project/SelectEmailFields.tpl
+++ b/pkg/vtiger/modules/Projects/Project/layouts/v7/modules/Project/SelectEmailFields.tpl
@@ -77,7 +77,7 @@
                 </div>
                 <div class="preferenceDiv" style="padding: 0px 0px 10px 35px;">
                     <label class="checkbox displayInlineBlock">
-                        <input type="checkbox" name="saveRecipientPrefs" id="saveRecipientPrefs" {if isset($RECIPIENT_PREF_ENABLED)}checked="true"{/if}/>&nbsp;&nbsp;&nbsp;
+                        <input type="checkbox" name="saveRecipientPrefs" id="saveRecipientPrefs" {if isset($RECIPIENT_PREF_ENABLED) && $RECIPIENT_PREF_ENABLED}checked="true"{/if}/>&nbsp;&nbsp;&nbsp;
                         {vtranslate('LBL_REMEMBER_MY_PREF',$MODULE)}&nbsp;&nbsp;
                     </label>
                     <i class="fa fa-info-circle" title="{vtranslate('LBL_EDIT_EMAIL_PREFERENCE_TOOLTIP', $MODULE)}"></i>
diff --git a/pkg/vtiger/modules/Projects/ProjectTask/layouts/v7/modules/ProjectTask/SelectEmailFields.tpl b/pkg/vtiger/modules/Projects/ProjectTask/layouts/v7/modules/ProjectTask/SelectEmailFields.tpl
index 8a6fc4415..0ab997725 100644
--- a/pkg/vtiger/modules/Projects/ProjectTask/layouts/v7/modules/ProjectTask/SelectEmailFields.tpl
+++ b/pkg/vtiger/modules/Projects/ProjectTask/layouts/v7/modules/ProjectTask/SelectEmailFields.tpl
@@ -20,9 +20,9 @@
                     <input type="hidden" name="viewname" value="{$VIEWNAME}" />
                     <input type="hidden" name="module" value="{$MODULE}"/>
                     <input type="hidden" name="view" value="ComposeEmail"/>
-                    <input type="hidden" name="search_key" value="{if isset($SEARCH_KEY)}{$SEARCH_KEY}{else}''{/if}"/>
+                    <input type="hidden" name="search_key" value="{if isset($SEARCH_KEY) && $SEARCH_KEY}{$SEARCH_KEY}{else}''{/if}"/>
                     <input type="hidden" name="operator" value="{$OPERATOR}" />
-                    <input type="hidden" name="search_value" value="{if isset($ALPHABET_VALUE)}{$ALPHABET_VALUE}{else}''{/if}" />
+                    <input type="hidden" name="search_value" value="{if isset($ALPHABET_VALUE) && $ALPHABET_VALUE}{$ALPHABET_VALUE}{else}''{/if}" />
                     {if isset($SEARCH_PARAMS)}
                         <input type="hidden" name="search_params" value='{ZEND_JSON::encode($SEARCH_PARAMS)}' />
                     {/if}
@@ -77,7 +77,7 @@
                 </div>
                 <div class="preferenceDiv" style="padding: 0px 0px 10px 35px;">
                     <label class="checkbox displayInlineBlock">
-                        <input type="checkbox" name="saveRecipientPrefs" id="saveRecipientPrefs" {if isset($RECIPIENT_PREF_ENABLED)}checked="true"{/if}/>&nbsp;&nbsp;&nbsp;
+                        <input type="checkbox" name="saveRecipientPrefs" id="saveRecipientPrefs" {if isset($RECIPIENT_PREF_ENABLED) && $RECIPIENT_PREF_ENABLED}checked="true"{/if}/>&nbsp;&nbsp;&nbsp;
                         {vtranslate('LBL_REMEMBER_MY_PREF',$MODULE)}&nbsp;&nbsp;
                     </label>
                     <i class="fa fa-info-circle" title="{vtranslate('LBL_EDIT_EMAIL_PREFERENCE_TOOLTIP', $MODULE)}"></i>
-- 
GitLab