From 7742b53182d423b57b99ccddd3a1177662122a81 Mon Sep 17 00:00:00 2001
From: Ruben Estrada <rulotec1@gmail.com>
Date: Mon, 17 Jun 2019 14:25:07 -0500
Subject: [PATCH] Order picklists according to sortorder configured by user
 when passed to customer portal through webservice.fix #1136

---
 include/Webservices/WebserviceField.php | 2 +-
 vtlib/Vtiger/Functions.php              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/Webservices/WebserviceField.php b/include/Webservices/WebserviceField.php
index c5add0d22..3499c3a19 100644
--- a/include/Webservices/WebserviceField.php
+++ b/include/Webservices/WebserviceField.php
@@ -378,7 +378,7 @@ class WebserviceField{
 		if ($moduleName == 'Events') $moduleName = 'Calendar';
 
 		if($numRows == 0){
-			$sql = "select * from vtiger_$fieldName";
+			$sql = "SELECT * FROM vtiger_$fieldName ORDER BY sortorderid";
 			$result = $this->pearDB->pquery($sql,array());
 			$numRows = $this->pearDB->num_rows($result);
 			for($i=0;$i<$numRows;++$i){
diff --git a/vtlib/Vtiger/Functions.php b/vtlib/Vtiger/Functions.php
index 4d80efb50..b2ab241f9 100644
--- a/vtlib/Vtiger/Functions.php
+++ b/vtlib/Vtiger/Functions.php
@@ -955,7 +955,7 @@ class Vtiger_Functions {
 
 	static function getPickListValuesFromTableForRole($tablename, $roleid) {
 		global $adb;
-		$query = "select $tablename from vtiger_$tablename inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_$tablename.picklist_valueid where roleid=? and picklistid in (select picklistid from vtiger_picklist) order by sortid";
+		$query = "select $tablename from vtiger_$tablename inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_$tablename.picklist_valueid where roleid=? and picklistid in (select picklistid from vtiger_picklist) order by sortorderid";
 		$result = $adb->pquery($query, array($roleid));
 		$fldVal = Array();
 		while ($row = $adb->fetch_array($result)) {
-- 
GitLab