diff --git a/data/CRMEntity.php b/data/CRMEntity.php
index bd63100b45c0cff8ba1803ea1d1f22e562019f0d..e44091c544dde7fbc32a09acc4536f194818cc22 100644
--- a/data/CRMEntity.php
+++ b/data/CRMEntity.php
@@ -2039,7 +2039,7 @@ class CRMEntity {
 	 */
 	function transferRelatedRecords($module, $transferEntityIds, $entityId) {
 		global $adb, $log;
-		$log->debug("Entering function transferRelatedRecords ($module, $transferEntityIds, $entityId)");
+		$log->debug("Entering function transferRelatedRecords ($module, ".implode(',',$transferEntityIds).", $entityId)");
 		foreach ($transferEntityIds as $transferId) {
 
 			// Pick the records related to the entity to be transfered, but do not pick the once which are already related to the current entity.
@@ -3008,6 +3008,7 @@ class CRMEntity {
 	 * @return string
 	 */
 	function getQueryForDuplicates($module, $tableColumns, $selectedColumns = '', $ignoreEmpty = false,$requiredTables = array(),$columnTypes = null) {
+		$query='';
 		if(is_array($tableColumns)) {
 			$tableColumnsString = implode(',', $tableColumns);
 		}
@@ -3058,6 +3059,7 @@ class CRMEntity {
 		}
 
 		$i = 1;
+		$duplicateCheckClause='';
 		foreach($tableColumns as $tableColumn){
 			$tableInfo = explode('.', $tableColumn);
 			$duplicateCheckClause .= " ifnull($tableColumn,'null') = ifnull(temp.$tableInfo[1],'null')";
diff --git a/include/ListView/ListViewSession.php b/include/ListView/ListViewSession.php
index 790aab9424c8c73ab322a76ea79456dd431546aa..168b08b1ec21a9ec28009bed9af2b3a9c2674267 100644
--- a/include/ListView/ListViewSession.php
+++ b/include/ListView/ListViewSession.php
@@ -76,6 +76,7 @@ class ListViewSession {
 		$cv = new CustomView();
 		$viewId = $cv->getViewId($currentModule);
 		$recordNavigationInfo = array();
+		$searchKey = array();
 		if(!empty($_SESSION[$currentModule.'_DetailView_Navigation'.$viewId])){
 			$recordNavigationInfo = Zend_Json::decode($_SESSION[$currentModule.'_DetailView_Navigation'.$viewId]);
 			$pageNumber =0;
diff --git a/include/fields/CurrencyField.php b/include/fields/CurrencyField.php
index 294438a77efaaac85382768bacc8b5a88feb36f2..ebad60bdec83691d1c232ee2702454f505cf10c8 100644
--- a/include/fields/CurrencyField.php
+++ b/include/fields/CurrencyField.php
@@ -125,6 +125,7 @@ class CurrencyField {
     public static function convertToUserFormat($value, $user=null, $skipConversion=false, $skipFormatting=false) {
 		// To support negative values
 		$negative = false;
+		if(!$value) return $value;
 		if(stripos($value, '-') === 0) {
 			$negative = true;
 			$value = substr($value, 1);
diff --git a/include/utils/EditViewUtils.php b/include/utils/EditViewUtils.php
index 48d0bb95b8f8b1ba389d49c642f600eb67469881..3b35f4924e1e1302d8b5b75febd8cbe6f2c91085 100755
--- a/include/utils/EditViewUtils.php
+++ b/include/utils/EditViewUtils.php
@@ -89,6 +89,7 @@ function getAssociatedProducts($module, $focus, $seid = '', $refModuleName = fal
 	$log->debug("Entering getAssociatedProducts(".$module.",".get_class($focus).",".$seid."='') method ...");
 	global $adb;
 	$output = '';
+	$taxtype = '';
 	global $theme,$current_user;
 
 	$no_of_decimal_places = getCurrencyDecimalPlaces();
@@ -468,8 +469,10 @@ function getAssociatedProducts($module, $focus, $seid = '', $refModuleName = fal
 		if($tax_percent == '' || $tax_percent == 'NULL')
 			$tax_percent = 0;
 		$taxamount = ($subTotal-$finalDiscount)*$tax_percent/100;
-        list($before_dot, $after_dot) = explode('.', $taxamount);
-        if($after_dot[$no_of_decimal_places] == 5) {
+		$split_taxamounts =explode('.', $taxamount);
+		$before_dot=isset($split_taxamounts[0]) ? $split_taxamounts[0] : '';
+		$after_dot=isset($split_taxamounts[1]) ? $split_taxamounts[1] : '';
+        if(isset($after_dot[$no_of_decimal_places]) && $after_dot[$no_of_decimal_places] == 5) {
             $taxamount = round($taxamount, $no_of_decimal_places, PHP_ROUND_HALF_UP); 
         } else {
             $taxamount = number_format($taxamount, $no_of_decimal_places,'.','');
diff --git a/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl b/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl
index 7f8a3dff92e6cb1388f8139a643b54405c14f7af..98878015f9306a3e7ace66413d895fc43795d363 100644
--- a/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl
+++ b/layouts/v7/modules/Inventory/partials/LineItemsContent.tpl
@@ -24,7 +24,7 @@
     {assign var="subprod_names" value="subprod_names"|cat:$row_no}
 	{assign var="subprod_qty_list" value="subprod_qty_list"|cat:$row_no}
     {assign var="entityIdentifier" value="entityType"|cat:$row_no}
-    {assign var="entityType" value=$data.$entityIdentifier}
+    {assign var="entityType" value=(isset($data.$entityIdentifier)) ? $data.$entityIdentifier : ""}
 
     {assign var="discount_type" value="discount_type"|cat:$row_no}
     {assign var="discount_percent" value="discount_percent"|cat:$row_no}
@@ -42,7 +42,7 @@
     {assign var="FINAL" value=$RELATED_PRODUCTS.1.final_details}
 
 	{assign var="productDeleted" value="productDeleted"|cat:$row_no}
-	{assign var="productId" value=$data[$hdnProductId]}
+	{assign var="productId" value=(isset($data[$hdnProductId])) ? $data[$hdnProductId] : ""}
 	{assign var="listPriceValues" value=Products_Record_Model::getListPriceValues($productId)}
 	{if $MODULE eq 'PurchaseOrder'}
 		{assign var="listPriceValues" value=array()}
@@ -57,7 +57,7 @@
 		&nbsp;<a><img src="{vimage_path('drag.png')}" border="0" title="{vtranslate('LBL_DRAG',$MODULE)}"/></a>
 		<input type="hidden" class="rowNumber" value="{$row_no}" />
 	</td>
-	{if $IMAGE_EDITABLE}
+	{if isset($IMAGE_EDITABLE) && $IMAGE_EDITABLE}
 		<td class='lineItemImage' style="text-align:center;">
 			<img src='{$data.$image}' height="42" width="42">
 		</td>
@@ -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="{$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="{$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 !$data.$productDeleted}
+							{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="{$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 class="col-lg-2">
 								{if $row_no eq 0}
@@ -90,7 +90,7 @@
 								{elseif $entityType eq '' and $SERVICE_ACTIVE eq 'true'}
 									<span class="lineItemPopup cursorPointer" data-popup="ServicesPopup" title="{vtranslate('Services',$MODULE)}" data-module-name="Services" data-field-name="serviceid">{Vtiger_Module_Model::getModuleIconPath('Services')}</span>
 								{else}
-									{if ($entityType eq 'Services') and (!$data.$productDeleted)}
+									{if ($entityType eq 'Services') and (isset($data.$productDeleted) && !$data.$productDeleted)}
 										<span class="lineItemPopup cursorPointer" data-popup="ServicesPopup" title="{vtranslate('Services',$MODULE)}" data-module-name="Services" data-field-name="serviceid">{Vtiger_Module_Model::getModuleIconPath('Services')}</span>
 									{elseif (!$data.$productDeleted)}
 										<span class="lineItemPopup cursorPointer" data-popup="ProductsPopup" title="{vtranslate('Products',$MODULE)}" data-module-name="Products" data-field-name="productid">{Vtiger_Module_Model::getModuleIconPath('Products')}</span>
@@ -101,9 +101,10 @@
 					</div>
 				</div>
 			</div>
-			<input type="hidden" value="{$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)}
 					{foreach key=SUB_PRODUCT_ID item=SUB_PRODUCT_INFO from=$data.$subprod_qty_list}
 						<em> - {$SUB_PRODUCT_INFO.name} ({$SUB_PRODUCT_INFO.qty})
 							{if $SUB_PRODUCT_INFO.qty > getProductQtyInStock($SUB_PRODUCT_ID)}
@@ -111,9 +112,11 @@
 							{/if}
 						</em><br>
 					{/foreach}
+				{/if}
+					
 				</span>
 			</div>
-			{if $data.$productDeleted}
+			{if isset($data.$productDeleted) && $data.$productDeleted}
 				<div class="row-fluid deletedItem redColor">
 					{if empty($data.$productName)}
 						{vtranslate('LBL_THIS_LINE_ITEM_IS_DELETED_FROM_THE_SYSTEM_PLEASE_REMOVE_THIS_LINE_ITEM',$MODULE)}
@@ -123,7 +126,7 @@
 				</div>
 			{else}
 				{if $COMMENT_EDITABLE}
-					<div><br><textarea id="{$comment}" name="{$comment}" class="lineItemCommentBox">{decode_html($data.$comment)}</textarea></div>
+					<div><br><textarea id="{$comment}" name="{$comment}" class="lineItemCommentBox">{(isset($data.$comment)) ? decode_html($data.$comment):""}</textarea></div>
 				{/if}
 			{/if}
 		</td>
@@ -134,26 +137,26 @@
 			   data-rule-required=true data-rule-positive=true data-rule-greater_than_zero=true value="{if !empty($data.$qty)}{$data.$qty}{else}1{/if}"
 			   {if $QUANTITY_EDITABLE eq false} disabled=disabled {/if} />
 
-		{if $PURCHASE_COST_EDITABLE eq false and $MODULE neq 'PurchaseOrder'}
+		{if isset($PURCHASE_COST_EDITABLE) && $PURCHASE_COST_EDITABLE eq false and $MODULE neq 'PurchaseOrder'}
 			<input id="{$purchaseCost}" type="hidden" value="{if ((float)$data.$purchaseCost)}{((float)$data.$purchaseCost) / ((float)$data.$qty)}{else}0{/if}" />
             <span style="display:none" class="purchaseCost">0</span>
 			<input name="{$purchaseCost}" type="hidden" value="{if $data.$purchaseCost}{$data.$purchaseCost}{else}0{/if}" />
 		{/if}
-		{if $MARGIN_EDITABLE eq false}
+		{if isset($MARGIN_EDITABLE) && $MARGIN_EDITABLE eq false}
 			<input type="hidden" name="{$margin}" value="{if $data.$margin}{$data.$margin}{else}0{/if}"></span>
 			<span class="margin pull-right" style="display:none">{if $data.$margin}{$data.$margin}{else}0{/if}</span>
 		{/if}
 		{if $MODULE neq 'PurchaseOrder'}
 			<br>
-			<span class="stockAlert redColor {if $data.$qty <= $data.$qtyInStock}hide{/if}" >
+			<span class="stockAlert redColor {if isset($data.$qty) && $data.$qty <= $data.$qtyInStock}hide{/if}" >
 				{vtranslate('LBL_STOCK_NOT_ENOUGH',$MODULE)}
 				<br>
-				{vtranslate('LBL_MAX_QTY_SELECT',$MODULE)}&nbsp;<span class="maxQuantity">{$data.$qtyInStock}</span>
+				{vtranslate('LBL_MAX_QTY_SELECT',$MODULE)}&nbsp;<span class="maxQuantity">{(isset($data.$qtyInStock)) ? $data.$qtyInStock:""}</span>
 			</span>
 		{/if}
 	</td>
 
-	{if $PURCHASE_COST_EDITABLE}
+	{if isset($PURCHASE_COST_EDITABLE) && $PURCHASE_COST_EDITABLE}
 		<td>
 			<input id="{$purchaseCost}" type="hidden" value="{if $data.$purchaseCost}{((float)$data.$purchaseCost) / ((float)$data.$qty)}{else}0{/if}" />
 			<input name="{$purchaseCost}" type="hidden" value="{if $data.$purchaseCost}{$data.$purchaseCost}{else}0{/if}" />
@@ -178,9 +181,9 @@
 					<span>(-)&nbsp;
 						<strong><a href="javascript:void(0)" class="individualDiscount">{vtranslate('LBL_DISCOUNT',$MODULE)}
 								<span class="itemDiscount">
-									{if $ITEM_DISCOUNT_PERCENT_EDITABLE && $data.$discount_type eq 'percentage'}
+									{if isset($data.$discount_type) && $ITEM_DISCOUNT_PERCENT_EDITABLE && $data.$discount_type eq 'percentage'}
 										({$data.$discount_percent}%)
-									{else if $ITEM_DISCOUNT_AMOUNT_EDITABLE && $data.$discount_type eq 'amount'}
+									{else if isset($data.$discount_type) && $ITEM_DISCOUNT_AMOUNT_EDITABLE && $data.$discount_type eq 'amount'}
 										({$data.$discount_amount})
 									{else}
 										(0)
@@ -196,13 +199,13 @@
 					{/if}
 					<input type="hidden" id="discount_type{$row_no}" name="discount_type{$row_no}" value="{$DISCOUNT_TYPE}" class="discount_type" />
 					<p class="popover_title hide">
-						{vtranslate('LBL_SET_DISCOUNT_FOR',$MODULE)} : <span class="variable">{$data.$productTotal}</span>
+						{vtranslate('LBL_SET_DISCOUNT_FOR',$MODULE)} : <span class="variable">{isset($data.$productTotal) && $data.$productTotal}</span>
 					</p>
 					<table width="100%" border="0" cellpadding="5" cellspacing="0" class="table table-nobordered popupTable">
 						<!-- TODO : discount price and amount are hide by default we need to check id they are already selected if so we should not hide them  -->
 						<tr>
 							<td>
-								<input type="radio" name="discount{$row_no}" {$data.$checked_discount_zero} {if empty($data.$discount_type)}checked{/if} class="discounts" data-discount-type="zero" />
+								<input type="radio" name="discount{$row_no}" {(isset($data.$checked_discount_zero)) ? $data.$checked_discount_zero:""} {if empty($data.$discount_type)}checked{/if} class="discounts" data-discount-type="zero" />
 								&nbsp;
 								{vtranslate('LBL_ZERO_DISCOUNT',$MODULE)}
 							</td>
@@ -214,25 +217,25 @@
 						{if $ITEM_DISCOUNT_PERCENT_EDITABLE}
 							<tr>
 								<td>
-									<input type="radio" name="discount{$row_no}" {$data.$checked_discount_percent} class="discounts" data-discount-type="percentage" />
+									<input type="radio" name="discount{$row_no}" {(isset($data.$checked_discount_percent)) ? $data.$checked_discount_percent : ""} class="discounts" data-discount-type="percentage" />
 									&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{$row_no}" name="discount_percentage{$row_no}" value="{$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}" {$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="{$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}
@@ -249,9 +252,9 @@
 			<span class="taxDivContainer">
 				<div class="taxUI hide" id="tax_div{$row_no}">
 					<p class="popover_title hide">
-						{vtranslate('LBL_SET_TAX_FOR',$MODULE)} : <span class="variable">{$data.$totalAfterDiscount}</span>
+						{vtranslate('LBL_SET_TAX_FOR',$MODULE)} : <span class="variable">{(isset($data.$totalAfterDiscount)) ? $data.$totalAfterDiscount : ""}</span>
 					</p>
-					{if $data.taxes && php7_count($data.taxes) > 0}
+					{if isset($data.taxes) && $data.taxes && php7_count($data.taxes) > 0}
 						<div class="individualTaxDiv">
 							<!-- we will form the table with all taxes -->
 							<table width="100%" border="0" cellpadding="5" cellspacing="0" class="table table-nobordered popupTable" id="tax_table{$row_no}">
@@ -279,16 +282,16 @@
 	{/if}
 
 	<td>
-		<div id="productTotal{$row_no}" align="right" class="productTotal">{if $data.$productTotal}{$data.$productTotal}{else}0{/if}</div>
+		<div id="productTotal{$row_no}" align="right" class="productTotal">{if isset($data.$productTotal) && $data.$productTotal}{$data.$productTotal}{else}0{/if}</div>
 		{if $ITEM_DISCOUNT_AMOUNT_EDITABLE || $ITEM_DISCOUNT_PERCENT_EDITABLE}
-			<div id="discountTotal{$row_no}" align="right" class="discountTotal">{if $data.$discountTotal}{$data.$discountTotal}{else}0{/if}</div>
-			<div id="totalAfterDiscount{$row_no}" align="right" class="totalAfterDiscount">{if $data.$totalAfterDiscount}{$data.$totalAfterDiscount}{else}0{/if}</div>
+			<div id="discountTotal{$row_no}" align="right" class="discountTotal">{if isset($data.$discountTotal) && $data.$discountTotal}{$data.$discountTotal}{else}0{/if}</div>
+			<div id="totalAfterDiscount{$row_no}" align="right" class="totalAfterDiscount">{if isset($data.$totalAfterDiscount) && $data.$totalAfterDiscount}{$data.$totalAfterDiscount}{else}0{/if}</div>
 		{/if}
 
-		<div id="taxTotal{$row_no}" align="right" class="productTaxTotal {if $IS_GROUP_TAX_TYPE}hide{/if}">{if $data.$taxTotal}{$data.$taxTotal}{else}0{/if}</div>
+		<div id="taxTotal{$row_no}" align="right" class="productTaxTotal {if $IS_GROUP_TAX_TYPE}hide{/if}">{if isset($data.$taxTotal) && $data.$taxTotal}{$data.$taxTotal}{else}0{/if}</div>
 	</td>
 
-	{if $MARGIN_EDITABLE && $PURCHASE_COST_EDITABLE}
+	{if isset($MARGIN_EDITABLE) && $MARGIN_EDITABLE && $PURCHASE_COST_EDITABLE}
 		<td>
 			<input type="hidden" name="{$margin}" value="{if $data.$margin}{$data.$margin}{else}0{/if}"></span>
 		<span class="margin pull-right">{if $data.$margin}{$data.$margin}{else}0{/if}</span>
@@ -296,6 +299,6 @@
 	{/if}
 
 	<td>
-		<span id="netPrice{$row_no}" class="pull-right netPrice">{if $data.$netPrice}{$data.$netPrice}{else}0{/if}</span>
+		<span id="netPrice{$row_no}" class="pull-right netPrice">{if isset($data.$netPrice) && $data.$netPrice}{$data.$netPrice}{else}0{/if}</span>
 	</td>
 {/strip}
diff --git a/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl b/layouts/v7/modules/Inventory/partials/LineItemsEdit.tpl
index 6942eda2b40a250c0ee568a72f6fe5fd750abe87..1551cc8fc7bad804e6009d65dacbac24731aabc1 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="{$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="" />
 
@@ -185,7 +185,7 @@
 						{include file="partials/LineItemsContent.tpl"|@vtemplate_path:'Inventory' row_no=0 data=[] IGNORE_UI_REGISTRATION=true}
 					</tr>
 					{foreach key=row_no item=data from=$RELATED_PRODUCTS}
-						<tr id="row{$row_no}" data-row-num="{$row_no}" class="lineItemRow" {if $data["entityType$row_no"] eq 'Products'}data-quantity-in-stock={$data["qtyInStock$row_no"]}{/if}>
+						<tr id="row{$row_no}" data-row-num="{$row_no}" class="lineItemRow" {if isset($data["entityType$row_no"]) && $data["entityType$row_no"] eq 'Products'}data-quantity-in-stock={$data["qtyInStock$row_no"]}{/if}>
 							{include file="partials/LineItemsContent.tpl"|@vtemplate_path:'Inventory' row_no=$row_no data=$data}
 						</tr>
 					{/foreach}
@@ -297,7 +297,7 @@
 						</td>
 					</tr>
 				{/if}
-				{if $SH_PERCENT_EDITABLE}
+				{if $SH_PERCENT_EDITABLE && isset($FINAL.chargesAndItsTaxes)}
 					{assign var=CHARGE_AND_CHARGETAX_VALUES value=$FINAL.chargesAndItsTaxes}
 					<tr>
 						<td width="83%">
@@ -337,7 +337,8 @@
 						<span class="pull-right"><strong>{vtranslate('LBL_PRE_TAX_TOTAL', $MODULE)} </strong></span>
 					</td>
 					<td>
-						{assign var=PRE_TAX_TOTAL value=$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>
@@ -360,7 +361,7 @@
 												   data-rule-positive=true data-rule-inventory_percentage=true />&nbsp;%
 										</td>
 										<td style="text-align: right;" class="lineOnTop">
-											<input type="text" size="6" name="{$tax_detail.taxname}_group_amount" id="group_tax_amount{$smarty.foreach.group_tax_loop.iteration}" style="cursor:pointer;" value="{$tax_detail.amount}" readonly class="cursorPointer span1 groupTaxTotal" />
+											<input type="text" size="6" name="{$tax_detail.taxname}_group_amount" id="group_tax_amount{$smarty.foreach.group_tax_loop.iteration}" style="cursor:pointer;" value="{(isset($tax_detail.amount))?$tax_detail.amount:''}" readonly class="cursorPointer span1 groupTaxTotal" />
 										</td>
 									</tr>
 								{/foreach}
@@ -394,7 +395,7 @@
 												{/if}
 												<tr>
 													{assign var=SH_TAX_VALUE value=$CHARGE_TAX_MODEL->getTax()}
-													{if $CHARGE_AND_CHARGETAX_VALUES[$CHARGE_ID]['value'] neq NULL}
+													{if isset($CHARGE_AND_CHARGETAX_VALUES[$CHARGE_ID]['value']) && $CHARGE_AND_CHARGETAX_VALUES[$CHARGE_ID]['value'] neq NULL}
 														{assign var=SH_TAX_VALUE value=0}
 														{if $CHARGE_AND_CHARGETAX_VALUES[$CHARGE_ID]['taxes'][$CHARGE_TAX_ID]}
 															{assign var=SH_TAX_VALUE value=$CHARGE_AND_CHARGETAX_VALUES[$CHARGE_ID]['taxes'][$CHARGE_TAX_ID]}
@@ -447,7 +448,7 @@
 							</div>
 						</td>
 						<td>
-							<span class="pull-right" id="deductTaxesTotalAmount">{if $FINAL.deductTaxesTotalAmount}{$FINAL.deductTaxesTotalAmount}{else}0{/if}</span>
+							<span class="pull-right" id="deductTaxesTotalAmount">{if isset($FINAL.deductTaxesTotalAmount) && $FINAL.deductTaxesTotalAmount}{$FINAL.deductTaxesTotalAmount}{else}0{/if}</span>
 						</td>
 					</tr>
 				{/if}
diff --git a/layouts/v7/modules/Vtiger/AddTagUI.tpl b/layouts/v7/modules/Vtiger/AddTagUI.tpl
index f693d2820697f944a73aea274c792b8d50f88d65..965e16607bff2619b7995235a4691df300d0dbf0 100644
--- a/layouts/v7/modules/Vtiger/AddTagUI.tpl
+++ b/layouts/v7/modules/Vtiger/AddTagUI.tpl
@@ -40,16 +40,19 @@
                                         <div class="dropdown-menu currentTagMenu">
                                             <div class="scrollable" style="max-height:300px">
                                                 <ul style="padding-left:0px;">
-                                                {foreach item=TAG_MODEL from=$ALL_USER_TAGS}
-                                                    {if array_key_exists($TAG_MODEL->getId(), $TAGS_LIST)}
-                                                        {continue}
-                                                    {/if} 
-                                                    <li class="tag-item list-group-item">
-                                                        <a style="margin-left:0px;">
-                                                            {include file="Tag.tpl"|vtemplate_path:$MODULE NO_DELETE=true NO_EDIT=true}
-                                                        </a>
-                                                    </li>
-                                                {/foreach}
+                                                {if isset($ALL_USER_TAGS)}
+                                                    {foreach item=TAG_MODEL from=$ALL_USER_TAGS}
+                                                        {if array_key_exists($TAG_MODEL->getId(), $TAGS_LIST)}
+                                                            {continue}
+                                                        {/if} 
+                                                        <li class="tag-item list-group-item">
+                                                            <a style="margin-left:0px;">
+                                                                {include file="Tag.tpl"|vtemplate_path:$MODULE NO_DELETE=true NO_EDIT=true}
+                                                            </a>
+                                                        </li>
+                                                    {/foreach}
+                                                {/if}
+                                           
                                                 <li class="dummyExistingTagElement tag-item list-group-item hide">
                                                     <a style="margin-left:0px;">
                                                         {assign var=TAG_MODEL value=Vtiger_Tag_Model::getCleanInstance()}
diff --git a/layouts/v7/modules/Vtiger/FindDuplicateContents.tpl b/layouts/v7/modules/Vtiger/FindDuplicateContents.tpl
index 51cc1b3fde8be07cc12b2ceafb400b44755b32d5..ca944eafefa1e030482f2725ce5f6d978ae38ce7 100644
--- a/layouts/v7/modules/Vtiger/FindDuplicateContents.tpl
+++ b/layouts/v7/modules/Vtiger/FindDuplicateContents.tpl
@@ -87,7 +87,7 @@
 					{/foreach}
 				{/foreach}
 			</table>
-			{if $recordCount eq 0}
+			{if isset($recordCount) && $recordCount eq 0}
 				<div class="col-md-12 col-sm-12 col-xs-12 col-lg-12 listViewContentDiv list-table-wrapper" id="listViewContents">
 					<table class="emptyRecordsDiv">
 						<tbody class="overflow-y">
diff --git a/layouts/v7/modules/Vtiger/MassEditForm.tpl b/layouts/v7/modules/Vtiger/MassEditForm.tpl
index 17f24de829f49a6282f7b00437c693f82d03864c..9b4a370356ef78aaf6106107c6b96032a1db33e7 100644
--- a/layouts/v7/modules/Vtiger/MassEditForm.tpl
+++ b/layouts/v7/modules/Vtiger/MassEditForm.tpl
@@ -19,7 +19,7 @@
             <input type="hidden" name="selected_ids" value={ZEND_JSON::encode($SELECTED_IDS)}>
             <input type="hidden" name="excluded_ids" value={ZEND_JSON::encode($EXCLUDED_IDS)}>
             <input type="hidden" name="tag_params" value={ZEND_JSON::encode($TAG_PARAMS)}>
-            <input type="hidden" name="search_params" value='{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)) : ""}' />
             <div>
                 <header class="overlayHeader" style='flex:0 0 auto;'>
                     {assign var=TITLE value="{vtranslate('LBL_MASS_EDITING',$MODULE)}"}
diff --git a/layouts/v7/modules/Vtiger/partials/SidebarEssentials.tpl b/layouts/v7/modules/Vtiger/partials/SidebarEssentials.tpl
index c6fe654cfb15b126e8eefacba45e4b30776bb7cd..bf43d357dbd9d85adb40a1ad61687180cd42739d 100644
--- a/layouts/v7/modules/Vtiger/partials/SidebarEssentials.tpl
+++ b/layouts/v7/modules/Vtiger/partials/SidebarEssentials.tpl
@@ -50,7 +50,7 @@
 										{assign var="SHARED_MEMBER_COUNT" value=1}
 										{/if}
 									{/foreach}
-									<li style="font-size:12px;" class='listViewFilter {if $VIEWID eq $CUSTOM_VIEW->getId() && ($CURRENT_TAG eq '')} active {if $smarty.foreach.customView.iteration gt 10} {assign var=count value=1} {/if} {else if $smarty.foreach.customView.iteration gt 10} filterHidden hide{/if} '> 
+									<li style="font-size:12px;" class='listViewFilter {if $VIEWID eq $CUSTOM_VIEW->getId() && (isset($CURRENT_TAG) && $CURRENT_TAG eq '')} active {if $smarty.foreach.customView.iteration gt 10} {assign var=count value=1} {/if} {else if $smarty.foreach.customView.iteration gt 10} filterHidden hide{/if} '> 
                                         {assign var=VIEWNAME value={vtranslate($CUSTOM_VIEW->get('viewname'), $MODULE)}}
 										{append var="CUSTOM_VIEW_NAMES" value=$VIEWNAME}
                                          <a class="filterName listViewFilterElipsis" href="{$LISTVIEW_URL|cat:'&viewname='|cat:$CUSTOM_VIEW->getId()|cat:'&app='|cat:$SELECTED_MENU_CATEGORY}" oncontextmenu="return false;" data-filter-id="{$CUSTOM_VIEW->getId()}" title="{$VIEWNAME|@escape:'html'}">{$VIEWNAME|@escape:'html'}</a> 
@@ -149,8 +149,9 @@
             <div class="menu-scroller scrollContainer" style="position:relative; top:0; left:0;">
                 <div class="list-menu-content">
                     <div id="listViewTagContainer" class="multiLevelTagList" 
-                    {if $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}">
+                    {if isset($TAGS)}
                         {foreach item=TAG_MODEL from=$TAGS name=tagCounter}
                             {assign var=TAG_LABEL value=$TAG_MODEL->getName()}
                             {assign var=TAG_ID value=$TAG_MODEL->getId()}
@@ -173,6 +174,7 @@
                         {/foreach}
                              </div>
                         </div>
+                    {/if}
                     </div>
                     {include file="AddTagUI.tpl"|vtemplate_path:$MODULE RECORD_NAME="" TAGS_LIST=array()}
                 </div>
diff --git a/layouts/v7/modules/Vtiger/uitypes/Salutation.tpl b/layouts/v7/modules/Vtiger/uitypes/Salutation.tpl
index 537cf772c4a25425fe8e3cacd6ae004b7f388340..ed6a34b6d8b48c1c95ff3b6a6ac9d3d19c4bff6c 100644
--- a/layouts/v7/modules/Vtiger/uitypes/Salutation.tpl
+++ b/layouts/v7/modules/Vtiger/uitypes/Salutation.tpl
@@ -14,7 +14,7 @@
 		<select class="inputElement select2" style="width:78px;" name="{$SALUTATION_FIELD_MODEL->get('name')}" >
 			{if $SALUTATION_FIELD_MODEL->isEmptyPicklistOptionAllowed()}<option value="">{vtranslate('LBL_NONE', $MODULE)}</option>{/if}
 			{foreach item=PICKLIST_VALUE key=PICKLIST_NAME from=$PICKLIST_VALUES}
-				<option value="{Vtiger_Util_Helper::toSafeHTML($PICKLIST_NAME)}" {if trim(decode_html($SALUTATION_FIELD_MODEL->get('fieldvalue'))) eq trim($PICKLIST_NAME)} selected {/if}>{$PICKLIST_VALUE}</option>
+				<option value="{Vtiger_Util_Helper::toSafeHTML($PICKLIST_NAME)}" {if isset($SALUTATION_FIELD_MODEL->get('fieldvalue')) && trim(decode_html($SALUTATION_FIELD_MODEL->get('fieldvalue'))) eq trim($PICKLIST_NAME)} selected {/if}>{$PICKLIST_VALUE}</option>
 			{/foreach}
 		</select>&nbsp;
 	{/if}
diff --git a/modules/Accounts/Accounts.php b/modules/Accounts/Accounts.php
index 1076fcf2bf8ff991ec442748c651d93616f5db52..3d7703a681435a66fbe530a7745cd6fae06f0590 100644
--- a/modules/Accounts/Accounts.php
+++ b/modules/Accounts/Accounts.php
@@ -993,7 +993,7 @@ class Accounts extends CRMEntity {
 	 */
 	function transferRelatedRecords($module, $transferEntityIds, $entityId) {
 		global $adb,$log;
-		$log->debug("Entering function transferRelatedRecords ($module, $transferEntityIds, $entityId)");
+		$log->debug("Entering function transferRelatedRecords ($module, ".implode(',',$transferEntityIds).", $entityId)");
 
 		$rel_table_arr = Array("Contacts"=>"vtiger_contactdetails","Potentials"=>"vtiger_potential","Quotes"=>"vtiger_quotes",
 					"SalesOrder"=>"vtiger_salesorder","Invoice"=>"vtiger_invoice","Activities"=>"vtiger_seactivityrel",
@@ -1646,6 +1646,7 @@ class Accounts extends CRMEntity {
 		$singular_modname = 'SINGLE_' . $related_module;
 
 		$button = '';
+		$query  = '';
 		if ($actions) {
 			if (is_string($actions))
 				$actions = explode(',', strtoupper($actions));
diff --git a/modules/Emails/Emails.php b/modules/Emails/Emails.php
index 655ce2c37f0a2bea8be9c2ead0b54bce540f653c..3663836f036d827a98a6cfc1df4a74fb7dae0848 100644
--- a/modules/Emails/Emails.php
+++ b/modules/Emails/Emails.php
@@ -181,7 +181,7 @@ class Emails extends CRMEntity {
 			//This is to added to store the existing attachment id of the contact where we should delete this when we give new image
 			foreach ($_FILES as $fileindex => $files) {
 				if ($files['name'] != '' && $files['size'] > 0) {
-					$files['original_name'] = vtlib_purify($_REQUEST[$fileindex . '_hidden']);
+					$files['original_name'] = isset($_REQUEST[$fileindex . '_hidden']) ? vtlib_purify($_REQUEST[$fileindex . '_hidden']):"";
 					$file_saved = $this->uploadAndSaveFile($id, $module, $files);
 				}
 			}
diff --git a/modules/Emails/models/Mailer.php b/modules/Emails/models/Mailer.php
index 71d7905064caeb5a9bce850ff49a702f74a69e6b..8741cdbce83f3def4a4d37c562c7d94bf499ec1e 100644
--- a/modules/Emails/models/Mailer.php
+++ b/modules/Emails/models/Mailer.php
@@ -12,7 +12,7 @@ include_once 'include/simplehtmldom/simple_html_dom.php';
 include_once 'libraries/InStyle/InStyle.php';
 include_once 'libraries/ToAscii/ToAscii.php';
 include_once 'include/database/PearDatabase.php';
-
+#[\AllowDynamicProperties]
 class Emails_Mailer_Model extends Vtiger_Mailer {
 
 	private $dom = null;
@@ -36,10 +36,13 @@ class Emails_Mailer_Model extends Vtiger_Mailer {
 	 */
 	public static function makeImageURLValid($htmlContent) {
 		$doc = new DOMDocument();
+		// set error level
+ 		$internalErrors = libxml_use_internal_errors(true);
 		$imageUrls = array();
 		if (!empty($htmlContent)) {
 			@$doc->loadHTML($htmlContent);
 			$tags = $doc->getElementsByTagName('img');
+			libxml_use_internal_errors($internalErrors);
 			foreach ($tags as $tag) {
 				$imageUrl = $tag->getAttribute('src');
 				$imageUrls[$imageUrl] = str_replace(" ", "%20", $imageUrl);
diff --git a/modules/HelpDesk/HelpDesk.php b/modules/HelpDesk/HelpDesk.php
index bc752466b0019d5d413c0cef9c3b7b5de78059a1..324584655ecbc47abe2a30cebd39e0425898e803 100644
--- a/modules/HelpDesk/HelpDesk.php
+++ b/modules/HelpDesk/HelpDesk.php
@@ -122,9 +122,9 @@ class HelpDesk extends CRMEntity {
 		$this->insertIntoAttachment($this->id,$module);
 
 		//service contract update
-		$return_action = $_REQUEST['return_action'];
-		$for_module = $_REQUEST['return_module'];
-		$for_crmid  = $_REQUEST['return_id'];
+		$return_action = isset($_REQUEST['return_action']) ? $_REQUEST['return_action'] : "";
+		$for_module = isset($_REQUEST['return_module']) ? $_REQUEST['return_module'] : "";
+		$for_crmid  = isset($_REQUEST['return_id']) ? $_REQUEST['return_id'] : "";
 		if ($return_action && $for_module && $for_crmid) {
 			if ($for_module == 'ServiceContracts') {
 				$on_focus = CRMEntity::getInstance($for_module);
diff --git a/modules/Inventory/models/Charges.php b/modules/Inventory/models/Charges.php
index 56e08e106113827c3ba856226164e23b96e7ec69..8c2f484b9886e9800a301c046eb1a2034e17cc74 100644
--- a/modules/Inventory/models/Charges.php
+++ b/modules/Inventory/models/Charges.php
@@ -64,7 +64,7 @@ class Inventory_Charges_Model extends Vtiger_Base_Model {
 	 * @return <Array> list of Inventory_TaxRecord_Model
 	 */
 	public function getSelectedTaxes($deleted = true) {
-		if (!$this->taxes) {
+		if (!isset($this->taxes)) {
 			$taxModelsList = array();
 			$isTaxable = $this->isTaxable();
 			if ($isTaxable) {
diff --git a/modules/Inventory/models/Record.php b/modules/Inventory/models/Record.php
index 8019e8a075f10375240099bce6816babfbf9b806..728a222a2b483a8415bb63d1e05a9bbe66518fe3 100644
--- a/modules/Inventory/models/Record.php
+++ b/modules/Inventory/models/Record.php
@@ -349,8 +349,8 @@ class Inventory_Record_Model extends Vtiger_Record_Model {
 
 		$productIdsList = array();
 		foreach ($productDetails as $key => $lineItemDetail) {
-			$productId	= $lineItemDetail['hdnProductId'.$key];
-			$entityType = $lineItemDetail['entityType'.$key];
+			$productId	= isset($lineItemDetail['hdnProductId'.$key]) ? $lineItemDetail['hdnProductId'.$key] : "";
+			$entityType = isset($lineItemDetail['entityType'.$key]) ? $lineItemDetail['entityType'.$key] : "";
 			$productIdsList[$entityType][] = $productId;
 		}
 
@@ -362,19 +362,18 @@ class Inventory_Record_Model extends Vtiger_Record_Model {
 
 		//Getting image details of each product
 		$imageDetailsList = array();
-		if ($productIdsList['Products']) {
+		if (isset($productIdsList['Products']) && $productIdsList['Products']) {
 			$imageDetailsList = Products_Record_Model::getProductsImageDetails($productIdsList['Products']);
 		}
 
 		foreach ($productDetails as $key => $lineItemDetail) {
-			$productId = $lineItemDetail['hdnProductId'.$key];
-			$entityType = $lineItemDetail['entityType'.$key];
-
+			$productId = isset($lineItemDetail['hdnProductId'.$key]) ? $lineItemDetail['hdnProductId'.$key] : "";
+			$entityType = isset($lineItemDetail['entityType'.$key]) ? $lineItemDetail['entityType'.$key] : "";
+			
 			//updating list price details
-			$productDetails[$key]['listPrice'.$key] = number_format((float)$convertedPriceDetails[$entityType][$productId], $numOfCurrencyDecimals, '.', '');
-
+			$productDetails[$key]['listPrice'.$key] = isset($convertedPriceDetails[$entityType][$productId]) ? number_format((float)$convertedPriceDetails[$entityType][$productId], $numOfCurrencyDecimals, '.', ''):"";			
 			//updating cost price details
-			$purchaseCost = (float)$userCurrencyInfo['conversion_rate'] * (float)$lineItemDetail['purchaseCost'.$key];
+			$purchaseCost = isset($lineItemDetail['purchaseCost'.$key]) ? (float)$userCurrencyInfo['conversion_rate'] * (float)$lineItemDetail['purchaseCost'.$key] :0;
 			$productDetails[$key]['purchaseCost'.$key] = number_format($purchaseCost, $numOfCurrencyDecimals, '.', '');
 
 			if($moduleName === 'PurchaseOrder') {
@@ -382,7 +381,7 @@ class Inventory_Record_Model extends Vtiger_Record_Model {
 			}
 
 			//Image detail
-			if ($imageDetailsList[$productId]) {
+			if (isset($imageDetailsList[$productId]) && $imageDetailsList[$productId]) {
 				$imageDetails = $imageDetailsList[$productId];
 				$productDetails[$key]['productImage'.$key] = $imageDetails[0]['path'].'_'.$imageDetails[0]['orgname'];
 			}
@@ -682,7 +681,7 @@ class Inventory_Record_Model extends Vtiger_Record_Model {
 		if ($chargeId) {
 			$chargeTaxModelsList = array();
 			$chargesAndItsTaxes = $this->getCharges();
-			$chargeInfo = $chargesAndItsTaxes[$chargeId];
+			$chargeInfo = isset($chargesAndItsTaxes[$chargeId]) ? $chargesAndItsTaxes[$chargeId] : "";
 			if ($chargeInfo && $chargeInfo['taxes']) {
 				$taxes = array_keys($chargeInfo['taxes']);
 				foreach ($taxes as $taxId) {
diff --git a/modules/Inventory/views/Edit.php b/modules/Inventory/views/Edit.php
index ee927809fcc47ee641038a5ed2416c9385f147d8..f6762d408fc2f610c08b4737421b2bdabddd08e3 100644
--- a/modules/Inventory/views/Edit.php
+++ b/modules/Inventory/views/Edit.php
@@ -120,7 +120,7 @@ Class Inventory_Edit_View extends Vtiger_Edit_View {
 			}
 		}
 
-		$deductTaxes = $relatedProducts ? $relatedProducts[1]['final_details']['deductTaxes'] : null;
+		$deductTaxes = $relatedProducts && isset($relatedProducts[1]['final_details']['deductTaxes']) ? $relatedProducts[1]['final_details']['deductTaxes'] : null;
 		if (!$deductTaxes) {
 			$deductTaxes = Inventory_TaxRecord_Model::getDeductTaxesList();
 		}
diff --git a/modules/Vtiger/actions/GetData.php b/modules/Vtiger/actions/GetData.php
index 148a59b8384b5d4c550d739e5e750b9ad9b1784e..d36dd292f980da25d673a2e4d163b5476d14838a 100644
--- a/modules/Vtiger/actions/GetData.php
+++ b/modules/Vtiger/actions/GetData.php
@@ -11,7 +11,7 @@
 class Vtiger_GetData_Action extends Vtiger_IndexAjax_View {
 
 	public function requiresPermission(\Vtiger_Request $request) {
-		$permissions = array('module_parameter' => 'source_module', 'action' => 'DetailView', 'record_parameter' => 'record');
+		$permissions[] = array('module_parameter' => 'source_module', 'action' => 'DetailView', 'record_parameter' => 'record');
 		return $permissions;
 	}
 	
diff --git a/modules/Vtiger/models/FindDuplicate.php b/modules/Vtiger/models/FindDuplicate.php
index d4889a24322777ce0e55ae66ce4d3c49882cb59b..fdd976672aa5018d6831d4718396e4b97e38afce 100644
--- a/modules/Vtiger/models/FindDuplicate.php
+++ b/modules/Vtiger/models/FindDuplicate.php
@@ -110,7 +110,7 @@ class Vtiger_FindDuplicate_Model extends Vtiger_Base_Model {
             $fieldValues[$group][$groupRecordCount]['recordid'] = $row['recordid'];
             foreach($row as $field => $value) {
                 if($i == 0 && $field != 'recordid') $temp[$field] = $value;
-                $fieldModel = $fieldModels[$field];
+                $fieldModel = isset($fieldModels[$field]) ? $fieldModels[$field] : "";
                 $resultRow[$field] = $value;
             }
             $fieldValues[$group][$groupRecordCount++] = $resultRow;
@@ -127,7 +127,7 @@ class Vtiger_FindDuplicate_Model extends Vtiger_Base_Model {
 	}
 
 	public function getRecordCount() {
-		if($this->rows) {
+		if(isset($this->rows)) {
 			$rows = $this->rows;
 		} else {
             $db = PearDatabase::getInstance();
diff --git a/modules/Vtiger/uitypes/Reference.php b/modules/Vtiger/uitypes/Reference.php
index 2769a45538a146f81e2e7e45f613f42c03e5a84f..de3e3442c7730d2922dd860fa675d518a7440f9b 100644
--- a/modules/Vtiger/uitypes/Reference.php
+++ b/modules/Vtiger/uitypes/Reference.php
@@ -68,6 +68,7 @@ class Vtiger_Reference_UIType extends Vtiger_Base_UIType {
 	 * @return link
 	 */
 	public function getEditViewDisplayValue($value) {
+		if(!$value) return '';
 		$referenceModule = $this->getReferenceModule($value);
 		if($referenceModule) {
 			$referenceModuleName = $referenceModule->get('name');
diff --git a/modules/Vtiger/views/FindDuplicates.php b/modules/Vtiger/views/FindDuplicates.php
index 8fd57af1f1d9d9a5b6315f915ee84962aba23490..9f3546bebfa1dfbb561f0b58877664cb6f3695de 100644
--- a/modules/Vtiger/views/FindDuplicates.php
+++ b/modules/Vtiger/views/FindDuplicates.php
@@ -109,7 +109,7 @@ class Vtiger_FindDuplicates_View extends Vtiger_List_View {
 		if(!$this->listViewHeaders){
 			$this->listViewHeaders = $dataModelInstance->getListViewHeaders();
 		}
-		if(!$this->rows) {
+		if(!isset($this->rows)) {
 			$this->rows = $dataModelInstance->getRecordCount();
 			$viewer->assign('TOTAL_COUNT', $this->rows);
 		}
diff --git a/modules/com_vtiger_workflow/VTJsonCondition.inc b/modules/com_vtiger_workflow/VTJsonCondition.inc
index 8da1bb117656c5119c95b1b843efb12b5dd89eb8..bfdf408b08ab70a3d8e42f070f283f15bf4cd3b4 100644
--- a/modules/com_vtiger_workflow/VTJsonCondition.inc
+++ b/modules/com_vtiger_workflow/VTJsonCondition.inc
@@ -32,7 +32,7 @@ class VTJsonCondition {
 				}
 				preg_match('/(\w+) : \((\w+)\) (\w+)/', $cond['fieldname'], $matches);
 				if (php7_count($matches) == 0) {
-					if ($cond['fieldname'] == '_VT_add_comment' && $cond['isEvaluated']) {
+					if (isset($cond['isEvaluated']) && $cond['fieldname'] == '_VT_add_comment' && $cond['isEvaluated']) {
 						$expressionResults[$conditionGroup][$i]['result'] = $cond['isEvaluated'];
 					} else {
 						$expressionResults[$conditionGroup][$i]['result'] = $this->checkCondition($entityData, $cond);
@@ -159,7 +159,7 @@ class VTJsonCondition {
 			}
 			$rawFieldValue = $fieldValue;
 		} else {
-			$fieldValue = $data[$cond['fieldname']];
+			$fieldValue = isset($data[$cond['fieldname']]) ? $data[$cond['fieldname']]:"";
 		}
 		$value = trim(html_entity_decode($cond['value']));
 		$expressionType = isset($cond['valuetype']) ? $cond['valuetype'] : null;
@@ -191,7 +191,7 @@ class VTJsonCondition {
 		global $current_user;
 		$handler = vtws_getModuleHandlerFromName($entityData->getModuleName(), $current_user);
 		$moduleFields = $handler->getMeta()->getModuleFields();
-		$fieldInstance = $moduleFields[$cond['fieldname']];
+		$fieldInstance = isset($moduleFields[$cond['fieldname']])?$moduleFields[$cond['fieldname']]:"";
 
 		if($fieldInstance && $fieldInstance->getFieldDataType() == 'datetime') {
 			//Convert the DB Date Time Format to User Date Time Format
diff --git a/pkg/vtiger/modules/ServiceContracts/modules/ServiceContracts/ServiceContractsHandler.php b/pkg/vtiger/modules/ServiceContracts/modules/ServiceContracts/ServiceContractsHandler.php
index 164932acbf61c0935296845e69b06633081d249d..bb1777499c01d93e959604e850abda3755e89291 100644
--- a/pkg/vtiger/modules/ServiceContracts/modules/ServiceContracts/ServiceContractsHandler.php
+++ b/pkg/vtiger/modules/ServiceContracts/modules/ServiceContracts/ServiceContractsHandler.php
@@ -44,7 +44,7 @@ class ServiceContractsHandler extends VTEventHandler {
 			$moduleName = $entityData->getModuleName();
 			
 			// Update Used Units for the Service Contract, everytime the status of a ticket related to the Service Contract changes
-			if ($moduleName == 'HelpDesk' && $_REQUEST['return_module'] != 'ServiceContracts') {
+			if (isset($_REQUEST['return_module']) && $moduleName == 'HelpDesk' && $_REQUEST['return_module'] != 'ServiceContracts') {
 				$ticketId = $entityData->getId();
 				$data = $entityData->getData();
 				if($data['ticketstatus'] != $entityData->oldStatus) {