diff --git a/layouts/v7/modules/Inventory/PopupEntries.tpl b/layouts/v7/modules/Inventory/PopupEntries.tpl
index 6f5eac44ef7e4a2e313304eedf3e466d2f20a09a..102067e4e5f746b503915e8206de2afc196b2c5b 100644
--- a/layouts/v7/modules/Inventory/PopupEntries.tpl
+++ b/layouts/v7/modules/Inventory/PopupEntries.tpl
@@ -64,7 +64,7 @@
                 {if $MODULE_MODEL && $MODULE_MODEL->isQuickSearchEnabled()}
                     <tr class="searchRow">
                         <td class="searchBtn textAlignCenter">
-                            <button class="btn" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
+                            <button class="btn btn-success" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
                         </td>
                         {foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
                             <td>
diff --git a/layouts/v7/modules/PriceBooks/ProductPriceBookPopupContents.tpl b/layouts/v7/modules/PriceBooks/ProductPriceBookPopupContents.tpl
index 1e528dcdfb1b0aba61e7ab2d43ad8d6faf23bc82..ce442ff0ae8f683f599903a759d85a09aa065871 100644
--- a/layouts/v7/modules/PriceBooks/ProductPriceBookPopupContents.tpl
+++ b/layouts/v7/modules/PriceBooks/ProductPriceBookPopupContents.tpl
@@ -66,7 +66,7 @@
                         {if $MODULE_MODEL && $MODULE_MODEL->isQuickSearchEnabled()}
                             <tr class="searchRow">
                                 <td class="searchBtn">
-                                    <button class="btn" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
+                                    <button class="btn btn-success" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
                                 </td>
                                 {foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
                                     <td>
diff --git a/layouts/v7/modules/Products/PriceBookProductPopupContents.tpl b/layouts/v7/modules/Products/PriceBookProductPopupContents.tpl
index 8b38e85a83220f08f5e389029ce34deaa51eaa3f..d8bb277e6f78a530239274e0608432527e2e539b 100644
--- a/layouts/v7/modules/Products/PriceBookProductPopupContents.tpl
+++ b/layouts/v7/modules/Products/PriceBookProductPopupContents.tpl
@@ -64,7 +64,7 @@
                         {if $MODULE_MODEL->isQuickSearchEnabled()}
                             <tr class="searchRow">
                                 <td class="searchBtn">
-                                    <button class="btn" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
+                                    <button class="btn btn-success" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
                                 </td>
                                 {foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
                                     <td>
diff --git a/layouts/v7/modules/Products/ProductsPopupContents.tpl b/layouts/v7/modules/Products/ProductsPopupContents.tpl
index 1418152d57c423801fff4bbac1b3738ef7d2011b..c51b25ccdc51f3b2a3a34ed7f5dfe52af512cb5b 100644
--- a/layouts/v7/modules/Products/ProductsPopupContents.tpl
+++ b/layouts/v7/modules/Products/ProductsPopupContents.tpl
@@ -55,7 +55,7 @@
                         {if $MODULE_MODEL && $MODULE_MODEL->isQuickSearchEnabled()}
                             <tr class="searchRow">
                                     <th class="textAlignCenter searchBtn">
-                                        <button class="btn pull-right pull-right" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
+                                        <button class="btn btn-success pull-right pull-right" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
                                     </th>
                                 {foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
                                     <th>
diff --git a/layouts/v7/modules/Reports/ListViewContents.tpl b/layouts/v7/modules/Reports/ListViewContents.tpl
index df647d0067030f76ff04cdf0aa7108ee6c846adf..40718d5d7ddac995353c8bbf9598d1f79c8af3b7 100644
--- a/layouts/v7/modules/Reports/ListViewContents.tpl
+++ b/layouts/v7/modules/Reports/ListViewContents.tpl
@@ -84,7 +84,7 @@
 										{assign var="DATA_TYPE" value=$LISTVIEW_HEADER['type']}
 										{if $DATA_TYPE == 'string'}
 											<div class="row-fluid">
-												<input type="text" name="{$LISTVIEW_HEADER_KEY}" class="listSearchContributor" value="{$SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['searchValue']}" data-fieldinfo='{$FIELD_INFO|escape}'/>
+												<input type="text" name="{$LISTVIEW_HEADER_KEY}" class="listSearchContributor inputElement" value="{$SEARCH_DETAILS[$LISTVIEW_HEADER_KEY]['searchValue']}" data-fieldinfo='{$FIELD_INFO|escape}'/>
 											</div>
 										{elseif $DATA_TYPE == 'picklist'}
 											{assign var=PICKLIST_VALUES value=Reports_Field_Model::getPicklistValueByField($LISTVIEW_HEADER_KEY)}
diff --git a/layouts/v7/modules/Vtiger/PopupContents.tpl b/layouts/v7/modules/Vtiger/PopupContents.tpl
index 63fd0cb493ab4b19443ea676fa8cfc70420e6f55..df21e84e7d4ac2c1a24cba3feb82f61aa8645f83 100644
--- a/layouts/v7/modules/Vtiger/PopupContents.tpl
+++ b/layouts/v7/modules/Vtiger/PopupContents.tpl
@@ -64,7 +64,7 @@
                 {if $MODULE_MODEL && $MODULE_MODEL->isQuickSearchEnabled()}
                     <tr class="searchRow">
                         <td class="textAlignCenter">
-                            <button class="btn" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
+                            <button class="btn btn-success" data-trigger="PopupListSearch">{vtranslate('LBL_SEARCH', $MODULE )}</button>
                         </td>
                         {foreach item=LISTVIEW_HEADER from=$LISTVIEW_HEADERS}
                             <td>
diff --git a/layouts/v7/modules/Vtiger/resources/Field.js b/layouts/v7/modules/Vtiger/resources/Field.js
index c1f00df1d28ca685d19031b0e43e6a66620e9a23..a7ca4a1ba0c54e379eca8d5763c62f361d46411f 100644
--- a/layouts/v7/modules/Vtiger/resources/Field.js
+++ b/layouts/v7/modules/Vtiger/resources/Field.js
@@ -163,6 +163,10 @@ jQuery.Class("Vtiger_Field_Js",{
 		}
 		if(this.isMandatory()) {
             addValidationToElement.attr('data-rule-required', 'true');
+			var type = this.getType();
+			if (type == 'reference') {
+				addValidationToElement.attr('data-rule-reference_required', 'true');
+			}
 		}
 		addValidationToElement.attr('data-fieldinfo',JSON.stringify(this.getData())).attr('data-specific-rules',JSON.stringify(this.getData().specialValidator));
         return element;
diff --git a/layouts/v7/modules/Vtiger/resources/validation.js b/layouts/v7/modules/Vtiger/resources/validation.js
index adcb026a93bacd736460fa19f7801d1faeff6ac0..5d45923746c1b267634ee501044246fbf0a28a1a 100644
--- a/layouts/v7/modules/Vtiger/resources/validation.js
+++ b/layouts/v7/modules/Vtiger/resources/validation.js
@@ -709,6 +709,18 @@ jQuery.validator.addMethod("RepeatMonthDate", function(value, element, params) {
 	}, jQuery.validator.format("Please enter the proper value")
 );
 
+jQuery.validator.addMethod("reference_required", function (value, element, params) {
+	var referenceValue = jQuery(element).parent().parent().find('input.sourceField').val();
+	if (isNaN(referenceValue)) {
+		referenceValue = jQuery(element).parent().parent().find('input.sourceField').attr('value');
+	}
+	if (referenceValue && parseInt(referenceValue) > 0) {
+		return true;
+	} else {
+		return false;
+	}
+}, jQuery.validator.format(app.vtranslate('JS_REQUIRED_FIELD')));
+
 function validateAndSubmitForm (form, params, meta) {
 	if(typeof meta === 'undefined' && typeof uimeta !== "undefined"){
 		meta = uimeta;
diff --git a/layouts/v7/modules/Vtiger/uitypes/Reference.tpl b/layouts/v7/modules/Vtiger/uitypes/Reference.tpl
index f28e28afc2bfb9d1acee28523d21f03ea529718e..460d1c9fef7ffa9d14fa885cd3203589884c42db 100644
--- a/layouts/v7/modules/Vtiger/uitypes/Reference.tpl
+++ b/layouts/v7/modules/Vtiger/uitypes/Reference.tpl
@@ -42,7 +42,7 @@
             value="{$FIELD_MODEL->getEditViewDisplayValue($displayId)}" 
             placeholder="{vtranslate('LBL_TYPE_SEARCH',$MODULE)}"
             {if $displayId neq 0}disabled="disabled"{/if}  
-            {if $FIELD_INFO["mandatory"] eq true} data-rule-required="true" {/if}
+            {if $FIELD_INFO["mandatory"] eq true} data-rule-required="true" data-rule-reference_required="true" {/if}
             {if count($FIELD_INFO['validator'])} 
                 data-specific-rules='{ZEND_JSON::encode($FIELD_INFO["validator"])}'
             {/if}
diff --git a/modules/Reports/ReportRun.php b/modules/Reports/ReportRun.php
index a8e52076ea77ba7c643b95042cb216808231ab64..85efeebd8c064456975c004619116a904ac3d7c1 100644
--- a/modules/Reports/ReportRun.php
+++ b/modules/Reports/ReportRun.php
@@ -2101,6 +2101,10 @@ class ReportRun extends CRMEntity {
 		if ($secmodule != '') {
 			$secondarymodule = explode(":", $secmodule);
 			foreach ($secondarymodule as $key => $value) {
+				if (!Vtiger_Module_Model::getInstance($value)) {
+					continue;
+				}
+
 				$foc = CRMEntity::getInstance($value);
 
 				// Case handling: Force table requirement ahead of time.
@@ -2113,10 +2117,12 @@ class ReportRun extends CRMEntity {
 						$query .= $focQuery . $this->getReportsNonAdminAccessControlQuery($value, $current_user, $value);
 					} else {
 						$query .= $focQuery . getNonAdminAccessControlQuery($value, $current_user, $value);
-						;
 					}
 				}
 			}
+			if ($this->queryPlanner->requireTable('vtiger_inventoryproductreltmp'.$value) && stripos($query, 'join vtiger_inventoryproductrel') === false) {
+				$query .= " LEFT JOIN vtiger_inventoryproductrel AS vtiger_inventoryproductreltmp$value ON vtiger_inventoryproductreltmp$value.id = $foc->table_name.$foc->table_index ";
+			}
 		}
 		$log->info("ReportRun :: Successfully returned getRelatedModulesQuery" . $secmodule);
 
@@ -3233,6 +3239,219 @@ class ReportRun extends CRMEntity {
 				}
 			}
 			return $totalpdf;
+		} elseif ($outputformat == 'XLS') {
+			$escapedchars = Array('_SUM', '_AVG', '_MIN', '_MAX');
+			$totalpdf = array();
+			$sSQL = $this->sGetSQLforReport($this->reportid, $filtersql, "COLUMNSTOTOTAL");
+			if (isset($this->totallist)) {
+				if ($sSQL != '') {
+					$result = $adb->query($sSQL);
+					$y = $adb->num_fields($result);
+					$custom_field_values = $adb->fetch_array($result);
+
+					static $mod_query_details = array();
+					foreach ($this->totallist as $key => $value) {
+						$fieldlist = explode(':', $key);
+						$key = $fieldlist[1].'_'.$fieldlist[2];
+						if (!isset($mod_query_details[$this->reportid][$key]['modulename']) && !isset($mod_query_details[$this->reportid][$key]['uitype'])) {
+							$mod_query = $adb->pquery('SELECT DISTINCT(tabid) AS tabid, uitype AS uitype FROM vtiger_field WHERE tablename = ? AND columnname=?', array($fieldlist[1], $fieldlist[2]));
+							$moduleName = getTabModuleName($adb->query_result($mod_query, 0, 'tabid'));
+							$mod_query_details[$this->reportid][$key]['translatedmodulename'] = getTranslatedString($moduleName, $moduleName);
+							$mod_query_details[$this->reportid][$key]['modulename'] = $moduleName;
+							$mod_query_details[$this->reportid][$key]['uitype'] = $adb->query_result($mod_query, 0, 'uitype');
+						}
+
+						if ($adb->num_rows($mod_query) > 0) {
+							$module_name = $mod_query_details[$this->reportid][$key]['modulename'];
+							$translatedModuleLabel = $mod_query_details[$this->reportid][$key]['translatedmodulename'];
+							$fieldlabel = trim(str_replace($escapedchars, ' ', $fieldlist[3]));
+							$fieldlabel = str_replace('_', ' ', $fieldlabel);
+							if ($module_name) {
+								$field = $translatedModuleLabel.' '.getTranslatedString($fieldlabel, $module_name);
+							} else {
+								$field = getTranslatedString($fieldlabel);
+							}
+						}
+						// Since there are duplicate entries for this table
+						if ($fieldlist[1] == 'vtiger_inventoryproductrel') {
+							$module_name = $this->primarymodule;
+						}
+						$uitype_arr[str_replace($escapedchars, ' ', $module_name.'_'.$fieldlist[3])] = $mod_query_details[$this->reportid][$key]['uitype'];
+						$totclmnflds[str_replace($escapedchars, ' ', $module_name.'_'.$fieldlist[3])] = $field;
+					}
+
+					$sumcount = 0;
+					$avgcount = 0;
+					$mincount = 0;
+					$maxcount = 0;
+					for ($i = 0; $i < $y; $i++) {
+						$fld = $adb->field_name($result, $i);
+						if (strpos($fld->name, '_SUM') !== false) {
+							$sumcount++;
+						} else if (strpos($fld->name, '_AVG') !== false) {
+							$avgcount++;
+						} else if (strpos($fld->name, '_MIN') !== false) {
+							$mincount++;
+						} else if (strpos($fld->name, '_MAX') !== false) {
+							$maxcount++;
+						}
+						$keyhdr[decode_html($fld->name)] = $custom_field_values[$i];
+					}
+
+					$rowcount = 0;
+					foreach ($totclmnflds as $key => $value) {
+						$col_header = trim(str_replace($modules, ' ', $value));
+						$fld_name_1 = $this->primarymodule.'_'.trim($value);
+						$fld_name_2 = $this->secondarymodule.'_'.trim($value);
+						if ($uitype_arr[$key] == 71 || $uitype_arr[$key] == 72 || $uitype_arr[$key] == 74 ||
+								in_array($fld_name_1, $this->append_currency_symbol_to_value) || in_array($fld_name_2, $this->append_currency_symbol_to_value)) {
+							$col_header .= ' ('.$app_strings['LBL_IN'].' '.$current_user->currency_symbol.')';
+							$convert_price = true;
+						} else {
+							$convert_price = false;
+						}
+						$value = trim($key);
+						$totalpdf[$rowcount]['Field Names'] = $col_header;
+						$originalkey = $value.'_SUM';
+						$arraykey = $this->replaceSpecialChar($value).'_SUM';
+						if (isset($keyhdr[$arraykey])) {
+							if ($convert_price) {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, false, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							} else {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							}
+							$totalpdf[$rowcount][$originalkey] = $conv_value;
+						} else if ($sumcount) {
+							$totalpdf[$rowcount][$originalkey] = '';
+						}
+
+						$originalkey = $value.'_AVG';
+						$arraykey = $this->replaceSpecialChar($value).'_AVG';
+						if (isset($keyhdr[$arraykey])) {
+							if ($convert_price) {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, false, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							} else {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							}
+							$totalpdf[$rowcount][$originalkey] = $conv_value;
+						} else if ($avgcount) {
+							$totalpdf[$rowcount][$originalkey] = '';
+						}
+
+						$originalkey = $value.'_MIN';
+						$arraykey = $this->replaceSpecialChar($value).'_MIN';
+						if (isset($keyhdr[$arraykey])) {
+							if ($convert_price) {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, false, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							} else {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							}
+							$totalpdf[$rowcount][$originalkey] = $conv_value;
+						} else if ($mincount) {
+							$totalpdf[$rowcount][$originalkey] = '';
+						}
+
+						$originalkey = $value.'_MAX';
+						$arraykey = $this->replaceSpecialChar($value).'_MAX';
+						if (isset($keyhdr[$arraykey])) {
+							if ($convert_price) {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, false, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey]);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							} else {
+								if ($operation == 'ExcelExport') {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true, true);
+									if ($uitype_arr[$key] == 74) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								} else {
+									$conv_value = CurrencyField::convertToUserFormat($keyhdr[$arraykey], null, true);
+									if (in_array($uitype_arr[$key], array(71, 72, 74))) {
+										$conv_value = CurrencyField::appendCurrencySymbol($conv_value, $userCurrencySymbol);
+									}
+								}
+							}
+							$totalpdf[$rowcount][$originalkey] = $conv_value;
+						} else if ($maxcount) {
+							$totalpdf[$rowcount][$originalkey] = '';
+						}
+						$rowcount++;
+					}
+					$totalpdf[$rowcount]['sumcount'] = $sumcount;
+					$totalpdf[$rowcount]['avgcount'] = $avgcount;
+					$totalpdf[$rowcount]['mincount'] = $mincount;
+					$totalpdf[$rowcount]['maxcount'] = $maxcount;
+				}
+			}
+			return $totalpdf;
 		} elseif ($outputformat == "TOTALHTML") {
 			$escapedchars = Array('_SUM', '_AVG', '_MIN', '_MAX');
 			$sSQL = $this->sGetSQLforReport($this->reportid, $filtersql, "COLUMNSTOTOTAL");
@@ -4015,7 +4234,7 @@ class ReportRun extends CRMEntity {
 
 		$reportData = $this->GenerateReport("PDF", $filterlist, false, false, false, 'ExcelExport');
 		$arr_val = $reportData['data'];
-		$totalxls = $this->GenerateReport("TOTALXLS", $filterlist, false, false, false, 'ExcelExport');
+		$totalxls = $this->GenerateReport("XLS", $filterlist, false, false, false, 'ExcelExport');
 		$numericTypes = array('currency', 'double', 'integer', 'percentage');
 
 		$header_styles = array(
@@ -4072,8 +4291,9 @@ class ReportRun extends CRMEntity {
 			$count = 0;
 			if (is_array($totalxls[0])) {
 				foreach ($totalxls[0] as $key => $value) {
-					$chdr = substr($key, -3, 3);
-					$translated_str = in_array($chdr, array_keys($mod_strings)) ? $mod_strings[$chdr] : $key;
+					$exploedKey = explode('_', $key);
+					$chdr = end($exploedKey);
+					$translated_str = in_array($chdr, array_keys($mod_strings)) ? $mod_strings[$chdr] : $chdr;
 					$worksheet->setCellValueExplicitByColumnAndRow($count, $rowcount, $translated_str);
 
 					$worksheet->getStyleByColumnAndRow($count, $rowcount)->applyFromArray($header_styles);
@@ -4082,12 +4302,20 @@ class ReportRun extends CRMEntity {
 				}
 			}
 
+			$ignoreValues = array('sumcount','avgcount','mincount','maxcount');
 			$rowcount++;
 			foreach ($totalxls as $key => $array_value) {
 				$count = 0;
 				foreach ($array_value as $hdr => $value) {
+					if (in_array($hdr, $ignoreValues)) {
+						continue;
+					}
 					$value = decode_html($value);
-					$worksheet->setCellValueExplicitByColumnAndRow($count, $key + $rowcount, $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+					$excelDatatype = PHPExcel_Cell_DataType::TYPE_STRING;
+					if (is_numeric($value)) {
+						$excelDatatype = PHPExcel_Cell_DataType::TYPE_NUMERIC;
+					}
+					$worksheet->setCellValueExplicitByColumnAndRow($count, $key + $rowcount, $value, $excelDatatype);
 					$count = $count + 1;
 				}
 			}
diff --git a/modules/Reports/ReportUtils.php b/modules/Reports/ReportUtils.php
index db2760fa9bdd6ea2043684e0ceb42e3600f3f39d..084658ec3bd4ce55ea3fba69d6654c1a0189e200 100644
--- a/modules/Reports/ReportUtils.php
+++ b/modules/Reports/ReportUtils.php
@@ -341,7 +341,7 @@ function getReportSearchCondition($searchParams, $filterId) {
 			$fieldName = $condition[0];
 			$searchValue = $condition[2];
 			if ($fieldName == 'reportname' || $fieldName == 'description') {
-				$conditionQuery .= " vtiger_report." . $fieldName . " LIKE ? ";
+				$conditionQuery .= " vtiger_report.$fieldName. LIKE ? ";
 				array_push($params, "%$searchValue%");
 			} else if ($fieldName == 'reporttype' || $fieldName == 'foldername' || $fieldName == 'owner') {
 				$searchValue = explode(',', $searchValue);
@@ -351,7 +351,13 @@ function getReportSearchCondition($searchParams, $filterId) {
 				if ($fieldName == 'reporttype' && in_array('tabular', $searchValue)) {
 					array_push($searchValue, 'summary');
 				}
-				$conditionQuery .= " vtiger_report." . $fieldName . " IN (" . generateQuestionMarks($searchValue) . ") ";
+				$conditionQuery .= " vtiger_report.$fieldName IN (".generateQuestionMarks($searchValue).") ";
+				foreach ($searchValue as $value) {
+					array_push($params, $value);
+				}
+			} else if ($fieldName == 'primarymodule') {
+				$searchValue = explode(',', $searchValue);
+				$conditionQuery .= " vtiger_reportmodules.$fieldName IN (".generateQuestionMarks($searchValue).") ";
 				foreach ($searchValue as $value) {
 					array_push($params, $value);
 				}
diff --git a/modules/Reports/models/Record.php b/modules/Reports/models/Record.php
index ee03e2a4593d5417053afd62e7756bcc0211d863..1181573d1dbea36c621d95969b67a84a149634e6 100644
--- a/modules/Reports/models/Record.php
+++ b/modules/Reports/models/Record.php
@@ -1086,6 +1086,9 @@ class Reports_Record_Model extends Vtiger_Record_Model {
 	 */
 	public function generateData($pagingModel = false) {
 		$filterQuery = $this->getAdvancedFilterSQL();
+		if (!$filterQuery) {
+			$filterQuery = true;
+		}
 		return $this->getReportData($pagingModel, $filterQuery);
 	}