diff --git a/include/QueryGenerator/QueryGenerator.php b/include/QueryGenerator/QueryGenerator.php index 8844692dd9cc25e0ce0e222757b4ede1ec1596f6..b5bbd0f9d424fe8ba590a955b19ede523999f148 100644 --- a/include/QueryGenerator/QueryGenerator.php +++ b/include/QueryGenerator/QueryGenerator.php @@ -1029,30 +1029,55 @@ class QueryGenerator { if(!$this->isStringType($field->getFieldDataType())) { $value = trim($value); } - if ($operator == 'empty' || $operator == 'y') { - $sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName(), $field)); - continue; - } - if($operator == 'ny'){ - $sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName(), $field)); - continue; - } - if ($operator == 'k') { + // If value is empty and comparator is equals then we have to check IS NULL (same as "is empty" condition) + if ($operator == 'empty' || $operator == 'y') { + $sqlFieldDataType = $field->getFieldDataType(); + if($sqlFieldDataType == 'date' || $sqlFieldDataType == 'birthday'){ + $sqlFormat = sprintf("IS NULL OR %s = '0000-00-00'", $this->getSQLColumn($field->getFieldName(), $field)); + } else if($sqlFieldDataType == 'datetime'){ + $sqlFormat = sprintf("IS NULL OR %s = '0000-00-00 00:00:00'", $this->getSQLColumn($field->getFieldName(), $field)); + } else { + $sqlFormat = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName(), $field)); + } + $sql[] = $sqlFormat; + continue; + } + if ($operator == 'ny') { + $sqlFieldDataType = $field->getFieldDataType(); + if ($sqlFieldDataType == 'date' || $sqlFieldDataType == 'birthday') { + $sqlFormat = sprintf("IS NOT NULL AND %s != '0000-00-00'", $this->getSQLColumn($field->getFieldName(), $field)); + } else if ($sqlFieldDataType == 'datetime') { + $sqlFormat = sprintf("IS NOT NULL AND %s != '0000-00-00 00:00:00'", $this->getSQLColumn($field->getFieldName(), $field)); + } else { + $sqlFormat = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName(), $field)); + } + $sql[] = $sqlFormat; + continue; + } + if ($operator == 'k') { $sql[] = sprintf("IS NULL OR %s NOT LIKE '%%%s%%'", $this->getSQLColumn($field->getFieldName(), $field), $value); continue; } - if((strtolower(trim($value)) == 'null') || - (trim($value) == '' && !$this->isStringType($field->getFieldDataType())) && - ($operator == 'e' || $operator == 'n')) { - if($operator == 'e'){ - $sql[] = "IS NULL"; - $sql[] = "= ''"; - continue; - } else { - $sql[] = "IS NOT NULL"; - $sql[] = "!= ''"; - continue; - } + $trimmedValue = is_array($value) ? NULL : trim($value); + if((strtolower($trimmedValue) == 'null') || + ($trimmedValue == '' && !$this->isStringType($field->getFieldDataType())) && + ($operator == 'e' || $operator == 'n')) { + if($operator == 'e'){ + $sql[] = "IS NULL"; + $sqlFieldDataType = $field->getFieldDataType(); + if($sqlFieldDataType == 'date' || $sqlFieldDataType == 'birthday'){ + $sql[] = "= '0000-00-00'"; + } else if($sqlFieldDataType == 'datetime'){ + $sql[] = "= '0000-00-00 00:00:00'"; + } else { + $sql[] = "= ''"; + } + continue; + } else { + $sql[] = "IS NOT NULL"; + $sql[] = "!= ''"; + continue; + } } elseif($field->getFieldDataType() == 'boolean') { $value = strtolower($value); if ($value == 'yes') { @@ -1096,11 +1121,11 @@ class QueryGenerator { } if($field->getFieldName() == 'birthday' && !$this->isRelativeSearchOperators( - $operator)) { - $value = "DATE_FORMAT(".$db->quote($value).", '%m%d')"; - } else { - $value = $db->sql_escape_string($value); - } + $operator)) { + $value = "DATE_FORMAT(".$db->quote($value).", '%m%d')"; + } else { + $value = is_array($value) ? NULL : $db->sql_escape_string($value); + } if(trim($value) == '' && ($operator == 's' || $operator == 'ew' || $operator == 'c') && ($this->isStringType($field->getFieldDataType()) || @@ -1150,14 +1175,32 @@ class QueryGenerator { $sql[] = "IS NULL"; } - if( ($field->getFieldName() != 'birthday' || ($field->getFieldName() == 'birthday' - && $this->isRelativeSearchOperators($operator)))){ - $value = "'$value'"; - } - - if(($this->isNumericType($field->getFieldDataType())) && empty($value)) { - $value = '0'; - } + /** + * While searching in decimal type columns, then value will be stored like 100.1234 (as float value). + * When user search for 100 then also it should show up 100.1234 for which we are altering comparator and + * value here. If we search 'equal' or 'not equal' we will change to 'like' or 'not like' + * NOTE : Same thing handled in ReportRun->generateAdvFilterSql() api + */ + if($this->isFloatType($field->getFieldDataType()) && !empty($value) + && in_array($operator, array('e', 'n') )){ + $sqlOperator = ($operator == 'e') ? ' LIKE ' : ' NOT LIKE '; + if ((float) $value == round((float)$value)) { + // if given value is witn out any decimals (Ex:- 1234), then we search with '1234.%' + $value = $value.'.'; + } + $value = $value."%"; + } + + if( ($field->getFieldDataType() != 'birthday' || ($field->getFieldDataType() == 'birthday' + && $this->isRelativeSearchOperators($operator)))){ + if($field->getFieldDataType() !== 'integer'){ + $value = "'$value'"; + } + } + + if($this->isNumericType($field->getFieldDataType()) && empty($value)) { + $value = '0'; + } $sql[] = "$sqlOperator $value"; } return $sql; @@ -1185,6 +1228,14 @@ class QueryGenerator { protected function isNumericType($type) { return ($type == 'integer' || $type == 'double' || $type == 'currency'); } + + /** + * Function to identify given type is a floating(decimal) type or not. Column types like decimal will store + * information as floating values. All those column related field types comes under this + */ + protected function isFloatType($type) { + return ($type == 'double' || $type == 'currency' || $type == 'multicurrency'); + } protected function isStringType($type) { return ($type == 'string' || $type == 'text' || $type == 'email' || $type == 'reference'); diff --git a/layouts/v7/modules/Documents/resources/Documents.js b/layouts/v7/modules/Documents/resources/Documents.js index 7d04c8e3424537418b913e8bc58573619896fa4f..ac8e4123aaec00a9f564f5cdff56cf0684be4a63 100644 --- a/layouts/v7/modules/Documents/resources/Documents.js +++ b/layouts/v7/modules/Documents/resources/Documents.js @@ -199,9 +199,9 @@ Vtiger.Class('Documents_Index_Js', { var fileParts = fileName.split('.'); var fileType = fileParts[fileParts.length - 1]; let notesTitle = container.find('[name="notes_title"]').val(); - if (!notesTitle.trim()) { + container.find('[name="notes_title"]').val(fileName.replace('.' + fileType, '')); - } + } }, diff --git a/layouts/v7/modules/Reports/resources/List.js b/layouts/v7/modules/Reports/resources/List.js index 8447e40ed9c08f99a3e42573bf2111d8352afd9d..fe9832937f3762edd294555a76f4c48abfcc9cf2 100644 --- a/layouts/v7/modules/Reports/resources/List.js +++ b/layouts/v7/modules/Reports/resources/List.js @@ -320,6 +320,7 @@ Vtiger_List_Js("Reports_List_Js",{ scrollInertia: 70, mouseWheel: {preventDefault: true} }; + jQuery('.quickPreviewSummary').trigger(Vtiger_Widget_Js.widgetPostLoadEvent); app.helper.showVerticalScroll(jQuery('.quickPreview .modal-body'), params); }); }, diff --git a/layouts/v7/modules/Vtiger/AdvanceSearch.tpl b/layouts/v7/modules/Vtiger/AdvanceSearch.tpl index 8404cce112ab2ce625977a7c8b67f680f8d15461..a63a1f2006eb33756dd5b3a5b0314b68e3ac74fd 100644 --- a/layouts/v7/modules/Vtiger/AdvanceSearch.tpl +++ b/layouts/v7/modules/Vtiger/AdvanceSearch.tpl @@ -55,7 +55,10 @@ </form> </div> {* </div>*} - </div></div></div> + </div></div> + <div class="searchResults"> + </div> + </div> <div class="modal-overlay-footer clearfix padding0px border0"> <div class="row clearfix"> <div class="col-lg-5 col-md-5 col-sm-5"> </div> @@ -84,8 +87,6 @@ <div> </div> </div> <div class="col-lg-2 col-md-1 hidden-xs hidden-sm"> </div> - <div class="searchResults"> - </div> </div></div> {/strip} diff --git a/layouts/v7/modules/Vtiger/resources/AdvanceSearch.js b/layouts/v7/modules/Vtiger/resources/AdvanceSearch.js index 0eda8c92168deb5c5072a762ad0dd98f31fd3a30..9283949184b7b88db039caa86afc46eb7a7d82b7 100644 --- a/layouts/v7/modules/Vtiger/resources/AdvanceSearch.js +++ b/layouts/v7/modules/Vtiger/resources/AdvanceSearch.js @@ -129,6 +129,9 @@ Vtiger_BasicSearch_Js("Vtiger_AdvanceSearch_Js",{ var thisInstance = this; this.getAdvanceSearch().then( function(data){ + jQuery('#advanceSearchButton').prop('disabled',false); + jQuery('#advanceSave').prop('disabled',false); + jQuery('#advanceIntiateSave').prop('disabled',false); thisInstance.showAdvanceSearch(data).then(function(){ thisInstance.setContainer(jQuery('#advanceSearchContainer')); vtUtils.showSelect2ElementView(thisInstance.getContainer().find('select.select2')); @@ -328,8 +331,10 @@ Vtiger_BasicSearch_Js("Vtiger_AdvanceSearch_Js",{ //To perform validation registration only once if(!this.filterValidationRegistered){ this.filterValidationRegistered = true; - controlForm.validationEngine({ - 'onValidationComplete' : validationDone + controlForm.vtValidate({ + success : function(){ + thisInstance.formValidationDeferred.resolve(); + } }); } //This will trigger the validation diff --git a/layouts/v7/modules/Vtiger/resources/Detail.js b/layouts/v7/modules/Vtiger/resources/Detail.js index c15a077d24a82479439fb54af97cdae4597aa1db..0b5eba6be41d4fcd9dd9c6ffda326b8e642df048 100644 --- a/layouts/v7/modules/Vtiger/resources/Detail.js +++ b/layouts/v7/modules/Vtiger/resources/Detail.js @@ -2533,8 +2533,8 @@ Vtiger.Class("Vtiger_Detail_Js",{ registerRelatedRowClickEvent: function() { var detailContentsHolder = this.getContentHolder(); detailContentsHolder.on('click','.relatedListEntryValues a',function(e){ - e.preventDefault(); - }); + e.stopPropagation(); + }); detailContentsHolder.on('click','.listViewEntries',function(e){ var selection = window.getSelection().toString(); if(selection.length == 0) { diff --git a/layouts/v7/modules/Vtiger/resources/dashboards/Widget.js b/layouts/v7/modules/Vtiger/resources/dashboards/Widget.js index 58b15c06d5ecbb1ae88e6ed2159f8fbe785e26db..cdcb65375111cebe81a11bee6758be7ae7e14240 100644 --- a/layouts/v7/modules/Vtiger/resources/dashboards/Widget.js +++ b/layouts/v7/modules/Vtiger/resources/dashboards/Widget.js @@ -304,8 +304,7 @@ Vtiger.Class('Vtiger_Widget_Js',{ }, openUrl : function(url) { - var win = window.open(url, '_blank'); - win.focus(); + window.open(url, '_blank'); } }); diff --git a/modules/Calendar/views/TaskManagement.php b/modules/Calendar/views/TaskManagement.php index 21b3e15411ce44f0889f9e00ff018e1ace986d64..d9c154120d9376d09a25a5bc626e2de5ca280bfb 100644 --- a/modules/Calendar/views/TaskManagement.php +++ b/modules/Calendar/views/TaskManagement.php @@ -117,8 +117,7 @@ class Calendar_TaskManagement_View extends Vtiger_Index_View { $color = $db->query_result($result,$i,'color'); } } - if(($color=='#ffffff') || ($color=' ')) - { + if($color=='#ffffff' || empty($color)) { $color = '#'.dechex(rand(0x000000, 0xFFFFFF)); } return $color; diff --git a/modules/Emails/views/MassSaveAjax.php b/modules/Emails/views/MassSaveAjax.php index 69c5a485bc35bbe9aeecedb998dc5a55c1b23f60..db74b8a1f015b44c34be00cb2da08464d0eaa8a6 100644 --- a/modules/Emails/views/MassSaveAjax.php +++ b/modules/Emails/views/MassSaveAjax.php @@ -196,11 +196,8 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { * Ex: for PDF: if filename - abc_md5(abc).pdf then raw filename - abc.pdf * For Normal documents: rawFileName is not exist in the attachments info. So it fallback to normal filename */ - $rawFileName = $existingAttachInfo['storedname']; - if (!$rawFileName) { - $rawFileName = $existingAttachInfo['attachment']; - } - $file_name = $existingAttachInfo['attachment']; + $rawFileName = $existingAttachInfo['attachment']; + $file_name = $existingAttachInfo['storedname']; $path = $existingAttachInfo['path']; $fileId = $existingAttachInfo['fileid']; @@ -210,7 +207,6 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { $oldFileName = $existingAttachInfo['fileid'].'_'.$file_name; } $oldFilePath = $path.'/'.$oldFileName; - $binFile = sanitizeUploadFileName($rawFileName, $upload_badext); $current_id = $adb->getUniqueID("vtiger_crmentity"); @@ -221,7 +217,8 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { //get the file path inwhich folder we want to upload the file $upload_file_path = decideFilePath(); - $newFilePath = $upload_file_path . $current_id . "_" . $binFile; + $encryptFileName = Vtiger_Util_Helper::getEncryptedFileName($binFile); + $newFilePath = $upload_file_path . $current_id . "_" . $encryptFileName; copy($oldFilePath, $newFilePath); @@ -229,9 +226,14 @@ class Emails_MassSaveAjax_View extends Vtiger_Footer_View { $params1 = array($current_id, $current_user->getId(), $ownerId, $moduleName . " Attachment", $recordModel->get('description'), $adb->formatDate($date_var, true), $adb->formatDate($date_var, true)); $adb->pquery($sql1, $params1); - $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)"; - $params2 = array($current_id, $filename, $recordModel->get('description'), $filetype, $upload_file_path); - $result = $adb->pquery($sql2, $params2); + // Inserting $encrypedFilename into the sql query + $sql2 = "INSERT INTO vtiger_attachments(attachmentsid, name, description, type, path, storedname) values(?, ?, ?, ?, ?, ?)"; + $params2 = array($current_id, $filename, $this->column_fields['description'], $filetype, $upload_file_path, $encryptFileName); + $adb->pquery($sql2, $params2); + // NOTE: Missing storedname columns in below code + // $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)"; + // $params2 = array($current_id, $filename, $recordModel->get('description'), $filetype, $upload_file_path); + // $result = $adb->pquery($sql2, $params2); $sql3 = 'insert into vtiger_seattachmentsrel values(?,?)'; $adb->pquery($sql3, array($recordModel->getId(), $current_id)); diff --git a/modules/PriceBooks/views/Popup.php b/modules/PriceBooks/views/Popup.php index f68c77a6eb3166bb1556df90b3259bd7f4cb0368..2cda1b71043739dfed5eee7d6b764d4d1ef11717 100644 --- a/modules/PriceBooks/views/Popup.php +++ b/modules/PriceBooks/views/Popup.php @@ -72,6 +72,9 @@ class PriceBooks_Popup_View extends Vtiger_Popup_View { } if(!empty($searchParams)) { + if(empty($searchParams[0][1])){ + $searchParams[0][]=array('currency_id','c',$currencyId); + } $transformedSearchParams = $this->transferListSearchParamsToFilterCondition($searchParams, $listViewModel->getModule()); $listViewModel->set('search_params',$transformedSearchParams); } diff --git a/modules/Reports/ReportRun.php b/modules/Reports/ReportRun.php index 1443776781980288f21028b8c0b527b804f70dd0..88f8cb8032a9897a470b78b10c8166b6c76f975b 100644 --- a/modules/Reports/ReportRun.php +++ b/modules/Reports/ReportRun.php @@ -3557,7 +3557,227 @@ class ReportRun extends CRMEntity { } } return $totalpdf; - } elseif ($outputformat == "TOTALHTML") { + /** + * Setting ouputformat == 'CSV' + * for multiple handling of sum, avg, min , max for csv format type + */ + } elseif ($outputformat == 'CSV') { + $escapedchars = array('_SUM', '_AVG', '_MIN', '_MAX'); + $totalpdf = array(); + $sSQL = $this->sGetSQLforReport($this->reportid, $filtersql, "COLUMNSTOTOTAL"); + if (isset($this->totallist)) { + if ($sSQL != '') { + $result = $adb->pquery($sSQL, array()); + $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 == 'CsvExport') { + $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 == 'CsvExport') { + $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 == 'CsvExport') { + $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 == 'CsvExport') { + $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 == 'CsvExport') { + $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 == 'CsvExport') { + $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 == 'CsvExport') { + $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 == 'CsvExport') { + $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"); @@ -4460,6 +4680,47 @@ class ReportRun extends CRMEntity { } } fclose($fp); + /** + * Adding $totalcsv to generate report getting data from fromat = "CSV" + */ + $totalcsv = $this->GenerateReport("CSV", $filterlist, false, false, false, 'CsvExport'); + if (!empty($totalcsv)) { + + $fp = fopen($fileName, 'a+'); + fputcsv($fp, array()); + + $size = sizeof($totalcsv); + + $headerCount = $totalcsv[$size - 1]; + + $headers = array('Field Names' => 'Field Names'); + + if ($headerCount['sumcount'] > 0) + $headers = array_merge($headers, array('SUM' => 'SUM')); + if ($headerCount['avgcount'] > 0) + $headers = array_merge($headers, array('AVG' => 'AVG')); + if ($headerCount['mincount'] > 0) + $headers = array_merge($headers, array('MIN' => 'MIN')); + if ($headerCount['maxcount'] > 0) + $headers = array_merge($headers, array('MAX' => 'MAX')); + + unset($totalcsv[$size - 1]); + + $colTotHdrs = array('0' => $headers); + + + foreach ($colTotHdrs as $key => $hdr) { + $hdr_values = $hdr; + fputcsv($fp, $hdr_values); + } + + foreach ($totalcsv as $key => $value) { + $csv_values = array_map('decode_html', $value); + fputcsv($fp, $csv_values); + } + ob_clean(); + fclose($fp); + } } function getGroupByTimeList($reportId) { diff --git a/modules/Reports/models/Chart.php b/modules/Reports/models/Chart.php index 10fbb99877103ad0386ddbae6bd55e026d358535..62ae4124b65e2221dce81f92b5c87451ef53c48f 100644 --- a/modules/Reports/models/Chart.php +++ b/modules/Reports/models/Chart.php @@ -359,33 +359,61 @@ abstract class Base_Chart extends Vtiger_Base_Model{ $filter = $reportRunObject->getAdvFilterList($reportModel->getId(), true); - // Special handling for date fields - $comparator = 'e'; - $dataFieldInfo = @explode(':', $field); - if(($dataFieldInfo[4] == 'D' || $dataFieldInfo[4] == 'DT') && !empty($dataFieldInfo[5])) { - $dataValue = explode(' ',$value); - if(php7_count($dataValue) > 1) { - $comparator = 'bw'; - if($dataFieldInfo[4] == 'D') { - $value = date('Y-m-d', strtotime($value)).','.date('Y-m-d', strtotime('last day of'.$value)); - } else { - $value = date('Y-m-d H:i:s' ,strtotime($value)).','.date('Y-m-d' ,strtotime('last day of'.$value)).' 23:59:59'; - } - } else { - $comparator = 'bw'; - if($dataFieldInfo[4] == 'D') { - $value = date('Y-m-d', strtotime('first day of JANUARY '.$value)).','.date('Y-m-d', strtotime('last day of DECEMBER '.$value)); - } else { - $value = date('Y-m-d H:i:s' ,strtotime('first day of JANUARY '.$value)).','.date('Y-m-d' ,strtotime('last day of DECEMBER '.$value)).' 23:59:59'; - } - } - } elseif($dataFieldInfo[4] == 'DT') { - $value = Vtiger_Date_UIType::getDisplayDateTimeValue($value); - } - - if(empty($value)) { - $comparator = 'empty'; - } + // Special handling for date fields + $comparator = 'e'; + $dataFieldInfo = @explode(':', $field); + if (($dataFieldInfo[4] == 'D' || $dataFieldInfo[4] == 'DT') && !empty($dataFieldInfo[5]) && !empty($value)) { + $dataValue = explode(' ', $value); + if ($dataFieldInfo[5] == 'WY') {//click through handling for group by week. + $comparator = 'bw'; + $dateRange = getWeekDateRange($value); + if ($dataFieldInfo[4] == 'D') { + $value = $dateRange[0] . ',' . $dateRange[1]; + } else { + $value = $dateRange[0] . ' 00:00:00' . ',' . $dateRange[1] . ' 23:59:59'; + } + } else if ($dataFieldInfo[5] == 'DD') { // click through handling for group by day + $comparator = 'bw'; + $value = date('Y-m-d H:i:s', strtotime($value)) . ',' . date('Y-m-d', strtotime($value)) . ' 23:59:59'; + } else if (php7_count($dataValue) > 1) { + $comparator = 'bw'; + if ($dataFieldInfo[4] == 'D') { + $value = date('Y-m-d', strtotime($value)) . ',' . date('Y-m-d', strtotime('last day of' . $value)); + } else { + $value = date('Y-m-d H:i:s', strtotime($value)) . ',' . date('Y-m-d', strtotime('last day of' . $value)) . ' 23:59:59'; + } + } else { + $comparator = 'bw'; + if ($dataFieldInfo[4] == 'D') { + $value = date('Y-m-d', strtotime('first day of JANUARY ' . $value)) . ',' . date('Y-m-d', strtotime('last day of DECEMBER ' . $value)); + } else { + $value = date('Y-m-d H:i:s', strtotime('first day of JANUARY ' . $value)) . ',' . date('Y-m-d', strtotime('last day of DECEMBER ' . $value)) . ' 23:59:59'; + } + } + + //Converting value to user format. + $valueParts = explode(',', $value); + foreach ($valueParts as $key => $valuePart) { + if ($dataFieldInfo[4] == 'DT') { + $value = explode(' ', trim($valuePart)); + $date = new DateTimeField($value[0]); + $valueParts[$key] = $date->getDisplayDate(); + } else { + $valueParts[$key] = Vtiger_Date_UIType::getDisplayDateValue(trim($valuePart)); + } + } + $value = implode(',', $valueParts); + } elseif ($dataFieldInfo[4] == 'DT') { + if (!empty($value) && $value != '0000-00-00 00:00:00') { + $value = Vtiger_Date_UIType::getDisplayDateTimeValue($value); + } + $value .= "," . $value; + } elseif ($dataFieldInfo[4] == 'D' && empty($dataFieldInfo[5]) && !empty($value)) { + $value = Vtiger_Date_UIType::getDisplayDateValue($value); + } + if (empty($value)) { + $comparator = 'empty'; + } $advancedFilterConditions = $reportModel->transformToNewAdvancedFilter(); //Step 1. Add the filter condition for the field @@ -797,4 +825,4 @@ class HorizontalbarChart extends VerticalbarChart { class LineChart extends VerticalbarChart{ -} \ No newline at end of file +} diff --git a/modules/Settings/LayoutEditor/actions/Field.php b/modules/Settings/LayoutEditor/actions/Field.php index c3de1b685d2d3e000bd300049c64b169abd88f9e..fdc339dfcc4c53b0720ee7fe6cbb03225759f785 100644 --- a/modules/Settings/LayoutEditor/actions/Field.php +++ b/modules/Settings/LayoutEditor/actions/Field.php @@ -101,7 +101,7 @@ class Settings_LayoutEditor_Field_Action extends Settings_Vtiger_Index_Action { if(!is_null($request->get('fieldDefaultValue', null))) { if(is_array($request->get('fieldDefaultValue'))) { - $defaultValue=decode_html(implode(', ',$request->get('fieldDefaultValue'))); + $defaultValue=decode_html(implode(' |##| ',$request->get('fieldDefaultValue'))); } else { $defaultValue = decode_html($request->get('fieldDefaultValue')); } diff --git a/modules/Settings/Vtiger/models/ConfigModule.php b/modules/Settings/Vtiger/models/ConfigModule.php index 09c10b560c2558d7c6df1d3e1175964df057420b..47ea1dacef4b2e69944ca5b51190f5cd1717f2c3 100644 --- a/modules/Settings/Vtiger/models/ConfigModule.php +++ b/modules/Settings/Vtiger/models/ConfigModule.php @@ -153,7 +153,7 @@ class Settings_Vtiger_ConfigModule_Model extends Settings_Vtiger_Module_Model { return "LBL_INVALID_EMAILID"; } else if(array_key_exists('HELPDESK_SUPPORT_NAME',$updatedFields) && preg_match ('/[\'";?><]/', $updatedFields['HELPDESK_SUPPORT_NAME'])) { return "LBL_INVALID_SUPPORT_NAME"; - } else if((array_key_exists('upload_maxsize',$updatedFields) && !filter_var(ltrim($updatedFields['upload_maxsize'],'0'), FILTER_VALIDATE_INT)) || (array_key_exists('list_max_entries_per_page',$updatedFields) && filter_var(ltrim($updatedFields['list_max_entries_per_page'], '0'), FILTER_VALIDATE_INT, array("options" => array("min_range"=>1, "max_range"=>100))) === false) || (array_key_exists('listview_max_textlength',$updatedFields) && filter_var(ltrim($updatedFields['listview_max_textlength'], '0'), FILTER_VALIDATE_INT , array("options" => array("min_range"=>1, "max_range"=>100))) === false)){ + } else if((array_key_exists('upload_maxsize',$updatedFields) && filter_var(ltrim($updatedFields['upload_maxsize'], '0'), FILTER_VALIDATE_INT, array("options" => array("min_range"=>1, "max_range"=>5))) === false) || (array_key_exists('list_max_entries_per_page',$updatedFields) && filter_var(ltrim($updatedFields['list_max_entries_per_page'], '0'), FILTER_VALIDATE_INT, array("options" => array("min_range"=>1, "max_range"=>100))) === false) || (array_key_exists('listview_max_textlength',$updatedFields) && filter_var(ltrim($updatedFields['listview_max_textlength'], '0'), FILTER_VALIDATE_INT , array("options" => array("min_range"=>1, "max_range"=>100))) === false)){ return "LBL_INVALID_NUMBER"; } return true; diff --git a/modules/Vtiger/actions/Save.php b/modules/Vtiger/actions/Save.php index 4a9c41dd78f172419a0cddda70f100df38b52c9c..f1e268c41a558ec087b1763772fb7b8db17e2da7 100644 --- a/modules/Vtiger/actions/Save.php +++ b/modules/Vtiger/actions/Save.php @@ -157,6 +157,9 @@ class Vtiger_Save_Action extends Vtiger_Action_Controller { foreach ($fieldModelList as $fieldName => $fieldModel) { $fieldValue = $request->get($fieldName, null); $fieldDataType = $fieldModel->getFieldDataType(); + if(is_array($fieldValue) && $fieldDataType == 'multipicklist'){ + $fieldValue=implode(' |##| ',$fieldValue); + } if($fieldDataType == 'time' && $fieldValue !== null){ $fieldValue = Vtiger_Time_UIType::getTimeValueWithSeconds($fieldValue); } diff --git a/modules/Vtiger/models/ListView.php b/modules/Vtiger/models/ListView.php index 64dfb4268eeeae21bb0fda8563c9b26a48be9d3a..980c105f423f3606287a318540f3c6c292b153ce 100644 --- a/modules/Vtiger/models/ListView.php +++ b/modules/Vtiger/models/ListView.php @@ -232,7 +232,6 @@ class Vtiger_ListView_Model extends Vtiger_Base_Model { $startIndex = $pagingModel->getStartIndex(); $pageLimit = $pagingModel->getPageLimit(); - $paramArray = array(); if(!empty($orderBy) && $orderByFieldModel) { if($orderBy == 'roleid' && $moduleName == 'Users'){ @@ -257,11 +256,9 @@ class Vtiger_ListView_Model extends Vtiger_Base_Model { ListViewSession::setSessionQuery($moduleName, $listQuery, $viewid); - $listQuery .= " LIMIT ?, ?"; - array_push($paramArray, $startIndex); - array_push($paramArray, ($pageLimit+1)); + $listQuery .= " LIMIT $startIndex,".($pageLimit+1); - $listResult = $db->pquery($listQuery, $paramArray); + $listResult = $db->pquery($listQuery, array()); $listViewRecordModels = array(); $listViewEntries = $listViewContoller->getListViewRecords($moduleFocus,$moduleName, $listResult); diff --git a/modules/Vtiger/views/ComposeEmail.php b/modules/Vtiger/views/ComposeEmail.php index 8b37aa2f50d5d566a4f99fa8c882dcbd95218a32..0f47423688d0565ad1c4f00a9a4df9826f866e44 100644 --- a/modules/Vtiger/views/ComposeEmail.php +++ b/modules/Vtiger/views/ComposeEmail.php @@ -429,6 +429,9 @@ class Vtiger_ComposeEmail_View extends Vtiger_Footer_View { $CC = Zend_Json::decode(html_entity_decode($recordModel->get('ccmail'))); $BCC = Zend_Json::decode(html_entity_decode($recordModel->get('bccmail'))); + // Under Condition CC & BCC fields are empty .. + $CC = is_array($CC) ? $CC : array(); + $BCC = is_array($BCC) ? $BCC : array(); $parentIds = explode('|',$recordModel->get('parent_id')); $toMailInfo = $toMailNamesList = array(); diff --git a/modules/Vtiger/views/ListAjax.php b/modules/Vtiger/views/ListAjax.php index 21282018a7123de8f51606c78ca0c95c3397b5ea..e822d42a8e038891c99d9c7ba031d3297939b224 100644 --- a/modules/Vtiger/views/ListAjax.php +++ b/modules/Vtiger/views/ListAjax.php @@ -151,7 +151,7 @@ class Vtiger_ListAjax_View extends Vtiger_List_View { $recordModel->setRawData($recordModel->getData()); foreach ($listViewModel->listViewHeaders as $fieldName => $fieldModel) { - $recordModel->set($fieldName, $fieldModel->getDisplayValue($recordModel->get($fieldName))); + $recordModel->set($fieldName, $fieldModel->getDisplayValue($recordModel->get($fieldName),$recordId)); } $listViewModel->listViewEntries[$recordId] = $recordModel; } diff --git a/modules/Vtiger/views/ShowWidget.php b/modules/Vtiger/views/ShowWidget.php index 43f88ad09f62cdbd91e197f101100cc2c3ee7308..44a71522fe75891ee3e9c5fa3b6bcaf4fc181772 100644 --- a/modules/Vtiger/views/ShowWidget.php +++ b/modules/Vtiger/views/ShowWidget.php @@ -47,6 +47,11 @@ class Vtiger_ShowWidget_View extends Vtiger_IndexAjax_View { $widget->set('data', $request->get('data')); } $widget->add(); + + if ($request->get('widgetid')) { + $widget->set('id', $request->get('widgetid')); + } + $request->set('widgetid', $widget->get('id')); } //Date conversion from user format to database format diff --git a/packages/vtiger/mandatory/Import.zip b/packages/vtiger/mandatory/Import.zip index facc92529c29e0d2fca17308eb9e773bb796993a..1e5043729d81f3a6245f59adee3d4a7c9dc57524 100644 Binary files a/packages/vtiger/mandatory/Import.zip and b/packages/vtiger/mandatory/Import.zip differ diff --git a/packages/vtiger/mandatory/MailManager.zip b/packages/vtiger/mandatory/MailManager.zip index 3deed01f07658554ec3dab6ef83af9414ba67ee9..493acbcac7ae154aece5479e37a5d11aa024372a 100644 Binary files a/packages/vtiger/mandatory/MailManager.zip and b/packages/vtiger/mandatory/MailManager.zip differ diff --git a/packages/vtiger/mandatory/Mobile.zip b/packages/vtiger/mandatory/Mobile.zip index 96d4b3c49669fc5bd30f4b3dbfe7e55865479d3b..bb230ae2e9d772a6c2664200a57a6903b87e3881 100644 Binary files a/packages/vtiger/mandatory/Mobile.zip and b/packages/vtiger/mandatory/Mobile.zip differ diff --git a/packages/vtiger/marketplace/ExtensionStore.zip b/packages/vtiger/marketplace/ExtensionStore.zip index 4ce403d0cd1747ca52891a7827d634ebc2e185f1..6bc386966000825b7e541509ee6f312d43b3d6f9 100644 Binary files a/packages/vtiger/marketplace/ExtensionStore.zip and b/packages/vtiger/marketplace/ExtensionStore.zip differ diff --git a/packages/vtiger/optional/EmailTemplates.zip b/packages/vtiger/optional/EmailTemplates.zip index 3b3cb6d0683e9bf54f6ff102d0325365d415716c..9d49c3cb38e39d95f4c018ab8047724a0ab33ca2 100644 Binary files a/packages/vtiger/optional/EmailTemplates.zip and b/packages/vtiger/optional/EmailTemplates.zip differ diff --git a/packages/vtiger/optional/Projects.zip b/packages/vtiger/optional/Projects.zip index 70a738b9221ac108e69ffa2137fdbc404264442c..a9cfdfa5456776b74ffa6cce71031e695220934a 100644 Binary files a/packages/vtiger/optional/Projects.zip and b/packages/vtiger/optional/Projects.zip differ diff --git a/packages/vtiger/optional/RecycleBin.zip b/packages/vtiger/optional/RecycleBin.zip index fe03be4c86e6507107788029e06da55dab2a0ba6..8e4ffbd38204d253202e76877688ca0dcc88dff6 100644 Binary files a/packages/vtiger/optional/RecycleBin.zip and b/packages/vtiger/optional/RecycleBin.zip differ diff --git a/packages/vtiger/optional/SMSNotifier.zip b/packages/vtiger/optional/SMSNotifier.zip index 773e2ed348ced132a2d42c6cf0a116eb155e951c..8df176a4fc89b95995bb3a3175361471c414a0cd 100644 Binary files a/packages/vtiger/optional/SMSNotifier.zip and b/packages/vtiger/optional/SMSNotifier.zip differ diff --git a/pkg/vtiger/modules/Projects/Project/modules/Project/models/Relation.php b/pkg/vtiger/modules/Projects/Project/modules/Project/models/Relation.php index cbd14356267cacec7c85938a8f75855ef4fd4c4d..72086687f5f3b9e25f311cbdc966e1524ab1139c 100644 --- a/pkg/vtiger/modules/Projects/Project/modules/Project/models/Relation.php +++ b/pkg/vtiger/modules/Projects/Project/modules/Project/models/Relation.php @@ -21,6 +21,7 @@ class Project_Relation_Model extends Vtiger_Relation_Model{ $destinationModuleName = $this->getRelationModuleModel()->get('name'); $sourceModuleFocus = CRMEntity::getInstance($sourceModuleName); $sourceModuleFocus->delete_related_module($sourceModuleName, $sourceRecordId, $destinationModuleName, $relatedRecordId); + $sourceModuleFocus->trackUnLinkedInfo($sourceModuleName, $sourceRecordId, $destinationModuleName, $relatedRecordId); return true; } }